mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 12:00:39 +00:00
8c7017a99d
- Update obioptions.Version from "Release 4.4.29" to "/v/ Release v5" - Update version.txt from 4.29 → .30 (automated by Makefile)
1.3 KiB
1.3 KiB
Semantic Description of GenerateSubcommandParser
The function GenerateSubcommandParser constructs a command-line argument parser with support for subcommands, leveraging the go-getoptions library.
-
It accepts:
program: The program name (used for help/version).documentation: A top-level description of the tool.setup: A callback to register subcommands and their options.
-
Internally:
- Initializes a
GetOptinstance with bundling mode (-abc) and strict unknown-option handling. - Registers global options (e.g.,
--debug,--verbose) that are inherited by all subcommands. - Invokes the user-provided
setupfunction to define subcommand-specific options and commands. - Automatically adds a built-in
helpsubcommand for command-level documentation.
- Initializes a
-
Returns:
- The root
*GetOpt, required to invoke.Dispatch(). - An
ArgumentParserfunction (signature:func([]string) (*GetOpt, []string)), which:- Parses command-line arguments (skipping
args[0], typically the binary name), - Handles errors via
ProcessParsedOptions, - Returns parsed state and remaining positional arguments.
- Parses command-line arguments (skipping
- The root
This design enables a clean, hierarchical CLI structure: global flags → subcommands → per-command options/positional args.