-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Category: Fossil IO
Component: Command-Line Parsing
Proposed Enhancement: Rewrite the command-line parser to support an easy-to-use command-line pallet with intelligent parsing capabilities, built-in options like --help, --version, --color, --verbose, and a variety of data types (bool, int, strings, arrays, etc.) while integrating subcommands and flags based on option types.
π Summary
This rewrite will enhance the current command-line parser to streamline parsing for smart, flexible command-line interfaces. The new system will have an intuitive approach to handling commands, subcommands, flags, subflags, and values. Additionally, it will automatically include common CLI options like --help, --version, --color, and --verbose. Options will support different types such as bool, int, strings, array, and even feature toggles, akin to Meson build system CLI parsing.
Weβll leverage string flags to simplify command and flag definitions, improving readability and user-friendliness. The default color scheme will make it easier for users to understand the output, with blue for text and light blue for values in color mode.
π‘ Motivation
- Current CLI parsing may be cumbersome, especially when adding new options and handling multiple types.
- Common CLI options like
--help,--version, and--verboseneed to be natively supported. - Parsing different option types, such as boolean flags, integers, and arrays, can be cumbersome and error-prone in the existing implementation.
- Enabling users to have more flexibility and clarity when dealing with complex command-line configurations is key.
π§ Proposed Features
-
Built-in CLI Options
--helpβ Displays usage information and options.--versionβ Outputs version information.--colorβ Toggles colorized output (defaults to blue for text, light blue for values).--verboseβ Enables verbose output.
-
Support for Multiple Option Types
- Boolean β Simple flags like
--verbose(true/false). - Integers β Use
--threads <number>to specify values (e.g.,--threads 4). - Strings β Basic text input, such as
--file <filename>. - Arrays β Use
--include <file1> <file2>to specify multiple values. - Feature Toggles (Enable/Disable/Auto) β Support flags like
--debug=<enable/disable/auto>where default could beauto.
- Boolean β Simple flags like
-
Subcommands and Flags
- Support for commands and subcommands with their own flags and values. E.g.:
command [subcommand] [flags]build --config debug --threads 4
- Support for commands and subcommands with their own flags and values. E.g.:
-
Color Mode and Text Customization
- Default color scheme: text will be blue, and light blue will be used for values in colorized output mode.
- The user can override the color scheme via
--coloroption.
-
Option Aliases and Simplicity
- Aliases for flags: Short flags like
-vfor--verbose, and-hfor--help. - Simplified, readable syntax for adding commands and subcommands, including array-based options or toggles.
- Ability to parse complex options efficiently (e.g.,
--config {enable,bold,underline}).
- Aliases for flags: Short flags like
π Location
- Core File: Update the
src/io/parser.cfor command parsing logic. - Helper File: Create or update
src/io/cli_options.cto define built-in options and how to handle their parsing. - Unit Tests: Create
tests/io/test_parser.cto validate the behavior of all new and existing CLI options, subcommands, and flags.
β Dependencies
- Minimal additional dependencies: Utilize basic string and argument manipulation methods from
cstring.h. - No external libraries required for core functionality (relying on custom parsing).
π οΈ Next Steps
- Define core CLI options (e.g.,
--help,--version,--color,--verbose) and set default behavior. - Implement flexible parsing that supports option types: boolean, integer, string, array, and feature toggles.
- Add subcommand support for easier, more modular CLI structures.
- Design the color mode logic to change default text formatting based on the
--colorflag.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status