doc/devdocs/cli-conventions.md
This document describes the conventions for implementing command-line interfaces (CLI) in PowerToys modules.
Use the System.CommandLine library for CLI argument parsing. This is already defined in Directory.Packages.props:
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
Add the reference to your project:
<PackageReference Include="System.CommandLine" />
--kebab-case for long form (e.g., --shrink-only).-x for short form (e.g., -s, -w).["--silent", "-s"].Option<T> with descriptive help text.RootCommand with a brief description.Parser(rootCommand).Parse(args) to parse CLI arguments.parseResult.GetValueForOption().Parser directly; RootCommand.Parse() may not be available with the pinned System.CommandLine version.Reference implementations:
src/modules/Awake/Awake/Program.cssrc/modules/imageresizer/ui/Cli/PrintUsage() method for custom help formatting if needed..editorconfig, StyleCop) and formatting rules.ManagedCommon.Logger for consistent logging.Main().src/modules/imageresizer/ui/Cli/CliLogger.cs0: Success1: General error (parsing, validation, runtime)2: Invalid arguments (optional)Main() in try-catch for unhandled exceptions.src/modules/[module]/tests/*CliTests.cs)..pipelines/ESRPSigning_core.json in the signing list.C:\Program Files\PowerToys\modules\[ModuleName]\).Common.SelfContained.props).