Expand description
Command line argument parsing using clap.
The args module defines the command-line argument structures and parsing logic for the bonds CLI application using the clap crate. It includes the main Cli struct, which represents the overall command-line interface, and the Commands enum, which defines the various subcommands that users can execute. Each subcommand may have its own set of arguments and options, allowing for a flexible and user-friendly command-line experience when managing directory bonds (symlinks with tracking).
Structs§
- Action
Flags - Defines common command-line flags that can be reused across multiple mutating commands in the bonds CLI application. The
dry_runflag allows users to preview the outcome of a command without making any actual changes to the filesystem or database, which is useful for testing and verification. Theverboseflag enables the printing of extra execution details, providing users with more insight into what the command is doing, which can be helpful for debugging and inspection purposes. By centralizing these flags in a single struct, we can maintain consistency and reduce redundancy across different commands that perform mutations. - Cli
- The
Clistruct defines the command-line interface for the bonds CLI application. It uses theclapcrate to parse command-line arguments and subcommands. Thedbfield allows users to specify a custom path to the database file, while thecommandfield represents the specific action that the user wants to perform, such as adding a new bond, listing existing bonds, or managing configuration. Each command is defined as a variant of theCommandsenum, which further organizes related actions into subcommands for better usability and clarity.
Enums§
- Commands
- The
Commandsenum defines the various commands that the bonds CLI application supports. Each variant corresponds to a specific action that can be performed on the bonds, such as adding a new bond, listing existing bonds, updating bond information, and managing metadata. Some commands have their own subcommands for more granular actions, such as theConfigandMetadatacommands. This structure allows for a clear and organized command-line interface, making it easier for users to understand and use the available functionality of the CLI application. - Config
Action - Subcommands for the
configcommand, which allows users to get or set configuration values for the bonds CLI application. TheGetvariant retrieves the current value of a specified configuration key, while theSetvariant updates a configuration key with a new value. This allows users to customize the behavior of the CLI application by modifying its configuration settings. - Metadata
Action - Subcommands for the
metadatacommand, which allows users to get, set, or remove metadata key-value pairs associated with a specific bond. TheGetvariant retrieves the value of a specified metadata key for a given bond, or all metadata if no key is provided. TheSetvariant updates or adds a metadata key-value pair for a specified bond. TheRemovevariant deletes a specific metadata key from a given bond. This functionality enables users to manage additional information about their bonds in a flexible way.