Skip to content

Add CLI mode for EFI boot manager#46

Merged
Inokinoki merged 6 commits intomasterfrom
claude/add-cli-mode-CRicZ
Dec 29, 2025
Merged

Add CLI mode for EFI boot manager#46
Inokinoki merged 6 commits intomasterfrom
claude/add-cli-mode-CRicZ

Conversation

@Inokinoki
Copy link
Owner

This commit implements a command-line interface (CLI) mode for QEFIEntryManager that is compatible with efibootmgr options, addressing issue #14.

Key features:

  • Automatic CLI/GUI mode detection based on command-line arguments
  • efibootmgr-compatible options for viewing and modifying boot entries
  • Support for boot order management, BootNext, timeout, and entry activation/deactivation
  • Verbose and quiet modes for flexible output
  • Comprehensive CLI documentation in CLI_README.md

Implementation details:

  • Created cli.h and cli.cpp for CLI handler logic
  • Modified main.cpp to detect CLI mode and branch to QCoreApplication
  • Updated CMakeLists.txt to include new CLI source files
  • Used QCommandLineParser for robust argument parsing

Supported efibootmgr options:

  • Display: -v (verbose), -q (quiet), -V (version)
  • Boot entry selection: -b (bootnum)
  • Modifications: -a (active), -A (inactive), -B (delete)
  • Boot order: -o (set order), -O (delete order)
  • BootNext: -n (set), -N (delete)
  • Timeout: -t (set), -T (delete)
  • Maintenance: -D (remove duplicates)

Note: Boot entry creation (-c, -C) is stubbed but not fully implemented yet. Users should use the GUI for creating new boot entries.

Closes #14

@Inokinoki Inokinoki self-assigned this Dec 29, 2025
This commit implements a command-line interface (CLI) mode for
QEFIEntryManager that is compatible with efibootmgr options, addressing
issue #14.

Key features:
- Automatic CLI/GUI mode detection based on command-line arguments
- efibootmgr-compatible options for viewing and modifying boot entries
- Support for boot order management, BootNext, timeout, and entry
  activation/deactivation
- Verbose and quiet modes for flexible output
- Comprehensive CLI documentation in CLI_README.md

Implementation details:
- Created cli.h and cli.cpp for CLI handler logic
- Modified main.cpp to detect CLI mode and branch to QCoreApplication
- Updated CMakeLists.txt to include new CLI source files
- Used QCommandLineParser for robust argument parsing

Supported efibootmgr options:
- Display: -v (verbose), -q (quiet), -V (version)
- Boot entry selection: -b (bootnum)
- Modifications: -a (active), -A (inactive), -B (delete)
- Boot order: -o (set order), -O (delete order)
- BootNext: -n (set), -N (delete)
- Timeout: -t (set), -T (delete)
- Maintenance: -D (remove duplicates)

Note: Boot entry creation (-c, -C) is stubbed but not fully implemented
yet. Users should use the GUI for creating new boot entries.

Closes #14

Signed-off-by: Inoki <veyx.shaw@gmail.com>
This commit adds a dedicated CLI-only executable and efibootmgr alias
as suggested in the second comment of issue #14.

Changes:
- Created qefibootmgr.cpp: Dedicated CLI-only executable
- Updated CMakeLists.txt to build qefibootmgr with minimal dependencies
  (Qt Core only, no GUI widgets)
- Added efibootmgr symlink installation on Unix-like systems
- Updated CLI_README.md to document the new executables

Benefits:
- qefibootmgr provides a lightweight CLI tool without GUI dependencies
- efibootmgr alias provides drop-in compatibility with standard efibootmgr
- Users can integrate into existing scripts that use efibootmgr
- Clear separation between GUI app and CLI tool

Usage:
  sudo qefibootmgr -v          # Use dedicated CLI tool
  sudo efibootmgr -v           # Use efibootmgr alias
  sudo QEFIEntryManager -v     # Use main app in CLI mode

Relates to #14

Signed-off-by: Inoki <veyx.shaw@gmail.com>
Updated the build system to create an efibootmgr executable on Windows
using the same source as qefibootmgr, instead of creating a separate
source file.

Changes:
- CMakeLists.txt: Build efibootmgr executable on Windows using
  qefibootmgr.cpp source
- CLI_README.md: Updated documentation to clarify Windows behavior
- Removed efibootmgr.cpp (not needed, reuse qefibootmgr.cpp)

On Windows, both qefibootmgr.exe and efibootmgr.exe are built from
the same source, providing drop-in compatibility without needing
symlinks (which require special permissions on Windows).

On Unix-like systems, efibootmgr remains as a symlink to qefibootmgr.

Relates to #14

Signed-off-by: Inoki <veyx.shaw@gmail.com>
This commit adds proper Windows administrator privilege handling for
the CLI executables by embedding UAC manifests.

Changes:
- CMakeLists.txt: Added UAC manifest for qefibootmgr and efibootmgr
  on Windows to request administrator elevation
- CLI_README.md: Added comprehensive Windows-specific documentation
  including UAC behavior, elevation requirements, and usage notes

Windows-specific improvements:
- Both CLI executables now include embedded manifests that trigger
  UAC elevation prompts automatically
- Documentation explains UAC behavior and scripting considerations

This ensures the CLI tools work correctly on Windows with proper
privilege elevation, matching the behavior of the GUI application.

Relates to #14

Signed-off-by: Inoki <veyx.shaw@gmail.com>
Replaced the markdown documentation with a proper Unix man page following
standard man page conventions.

Changes:
- Added qefibootmgr.8: Comprehensive man page for qefibootmgr/efibootmgr
  in standard groff format with all sections (NAME, SYNOPSIS, DESCRIPTION,
  OPTIONS, EXAMPLES, etc.)
- Removed CLI_README.md: Replaced with traditional man page documentation
- Updated CMakeLists.txt: Install man page to ${CMAKE_INSTALL_MANDIR}/man8
  on Unix-like systems

The man page includes:
- Complete option documentation compatible with efibootmgr
- Usage examples for common operations
- Platform-specific notes (Linux, FreeBSD, Windows)
- Exit status codes
- Compatibility notes
- Requirements and limitations

Users can now access documentation via:
  man qefibootmgr
  man efibootmgr

Relates to #14

Signed-off-by: Inoki <veyx.shaw@gmail.com>
This commit fixes all issues identified in code review that caused
CI build failures and would cause runtime problems.

Critical fixes:
1. Removed unused qefiloadoptioneditorview.h include from cli.cpp
   - This header depends on QtWidgets (QWidget base class)
   - qefibootmgr only links Qt::Core, not Qt::Widgets
   - Including it caused build failures in all CIs

2. Added destructor to CLI class to fix memory leak
   - QCoreApplication was allocated with new but never deleted
   - Added ~CLI() destructor to properly clean up

3. Fixed handleModifications() return logic
   - Was returning false when no modifications made (not an error!)
   - Caused exit code 1 on successful operations like "qefibootmgr -D"
     when no duplicates found
   - Now returns true for success, false only for actual errors

4. Added validation for conflicting options
   - Detect when both --active and --inactive are specified
   - Return error instead of silently preferring --active

5. Modernized CMake syntax
   - Replaced deprecated LINK_FLAGS property
   - Use target_link_options() for UAC manifest

All fixes tested and ready for CI re-run.

Fixes build failures in all CI platforms (Linux, Windows, FreeBSD).

Signed-off-by: Inoki <veyx.shaw@gmail.com>
@Inokinoki Inokinoki force-pushed the claude/add-cli-mode-CRicZ branch from 2352528 to 244cc3d Compare December 29, 2025 08:35
@Inokinoki Inokinoki merged commit 05e072e into master Dec 29, 2025
7 checks passed
@Inokinoki Inokinoki deleted the claude/add-cli-mode-CRicZ branch December 29, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Add command line

1 participant