Skip to content

Implement CLI subcommands #39

@Sstark97

Description

@Sstark97

Phase 5: CLI Presentation

Implement CLI subcommands using DotMake.CommandLine (source generators, AOT-compatible).

Commands to Implement

In Infrastructure/Cli/Commands/:

RootCommand

  • No arguments → Interactive mode (shows menu)
  • Entry point for the application
  • Delegates to InteractiveMenu

AnalyzeCommand

devsweep analyze [modules]
devsweep analyze jetbrains docker
devsweep analyze --all
  • Accepts module names as arguments
  • Calls IAnalyzeUseCase.ExecuteAsync()
  • Displays results via IOutputFormatter

CleanCommand

devsweep clean [modules] [options]
devsweep clean jetbrains homebrew
devsweep clean devtools --nuclear
devsweep clean --all
  • Accepts module names as arguments
  • --nuclear flag (requires devtools module)
  • Calls ICleanupUseCase.ExecuteAsync()

VersionCommand

devsweep version
  • Displays version number
  • Reads from assembly metadata

Global Options

All commands support:

  • --dry-run, -d: Preview without deleting
  • --force, -f, -y: Skip confirmations (not nuclear)
  • --verbose: Detailed output
  • --output <format>: rich (default) | plain | json

Implementation with DotMake.CommandLine

[CliCommand(Description = "Developer disk cleanup tool")]
public class RootCommand
{
    [CliOption(Description = "Preview actions", Aliases = new[] { "-d" })]
    public bool DryRun { get; set; }
    
    [CliOption(Description = "Output format")]
    public OutputFormat Output { get; set; } = OutputFormat.Rich;
    
    // ... more options
}

Validation

  • Nuclear mode requires devtools module
  • Module names must be valid (jetbrains, docker, homebrew, devtools, projects, system)
  • Cannot combine analyze and clean in single command

Tests Required

All in tests/Infrastructure/Cli/Commands/:

  • RootCommandTests: Interactive mode, help, version
  • AnalyzeCommandTests: Module selection, --all flag
  • CleanCommandTests: Module selection, nuclear validation
  • VersionCommandTests: Version display

Port argument parsing tests from bash tests/unit/cli_test.sh.

Definition of Done

  • All commands implemented with DotMake.CommandLine
  • Source generators working (zero reflection)
  • All bash CLI tests ported
  • Help text clear and useful
  • AOT compilation verified

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions