Crate wca

source ·
Expand description

The tool to make CLI ( commands user interface ). It is able to aggregate external binary applications, as well as functions, which are written in your language.

Diagrams

Class diagram

  • Parser

This component takes in raw strings of text and converts them into RawCommand objects. These objects contain all of the information needed to represent a command, but they haven’t been validated or processed in any way yet.

  • Grammar

Contains available commands configured by the user.

Once the RawCommand objects have been generated, the Grammar component steps in. This component takes in the RawCommand-s and converts them into GrammarCommand objects, which contain subject and property values that have been validated against a set of pre-defined grammar. This ensures that the user’s input is structured correctly and can be understood by the system.

  • Executor

Contains available routines configured by the user.

Once the GrammarCommand objects have been generated, the Executor component takes over. This component converts the GrammarCommands into ExecutableCommand objects, which contain the actual routines that will be executed at runtime. This is where the system takes action based on the user’s input.

  • CommandsAggregator

Finally, the CommandsAggregator component brings everything together. This component is responsible for configuring the Parser, Grammar, and Executor components based on the user’s needs. It also manages the entire pipeline of processing, from parsing the raw text input to executing the final command(parse -> validate -> execute).

Sequence diagram

Modules

  • Commands aggregator library.
  • This component is responsible for aggregating all commands
  • This component is responsible for performing
  • Exposed namespace of the module.
  • The missing batteries of WCA.
  • Performs validation and type casting on commands values
  • User input
  • Orphan namespace of the module.
  • This component is responsible for parsing the raw string into RawCommand
  • Prelude to use essentials: use my_module::prelude::*.
  • Protected namespace of the module.
  • Tools

Macros

Structs

  • Command Args
  • Command descriptor.
  • A builder struct for constructing commands.
  • The CommandsAggregator struct is responsible for aggregating all commands that the user defines, and for parsing and executing them. It is the main entry point of the library.
  • Container for contexts values
  • Represents a command that can be executed, with a list of command subjects and a set of command options, and a callback function that defines the command logic.
  • Executor that is responsible for executing the program’s commands. It uses the given Context to store and retrieve values during runtime.
  • This is the struct that provides a way to convert a GrammarCommand to an ExecutableCommand.
  • Represents a grammatically correct command with a phrase descriptor, a list of command subjects, and a set of command options.
  • Converts a RawCommand to a GrammarCommand by performing validation and type casting on values.
  • Represents a namespace of commands with the specified Command type. This is done to be flexible and not to duplicate code.
  • Parser provides parsing command strings into RawCommand objects. It allows you to specify the symbols that will be used to interpret the command string, such as the command delimiter, property delimiter, and namespace delimiter.
  • Represents a program that contains one or more namespaces, where each namespace contains a list of commands.
  • A struct representing a property.
  • Command Properties
  • Represents a parsed command that has been extracted from an input string by a Parser.
  • Represents the state of the program’s runtime, including the current context, execution position, and namespace of executable commands.
  • State of a program runtime

Enums

  • Errors that can occur in application.
  • Represents the type of executor to use for running commands.
  • Available help commands variants
  • Routine handle.
  • Available types that can be converted to a Value
  • Validation errors that can occur in application.
  • Container for a Value of a specific type

Traits

Functions

  • Ask use input from standard input.
  • Creates a command-line interface (CLI) builder with the given initial state.