33//! This module contains the command line interface of the application.
44//!
55//! The command line parsing is implemented using the `clap` library.
6- //! The module is defining types to represent a structured form of the
7- //! program invocation. The `Arguments` type is used to represent all
8- //! possible invocations of the program.
6+ //! The module defines types to represent a structured form of program invocation.
7+ //! The `Arguments` type is used to represent all possible invocations of the program.
98
109use clap:: { arg, command, ArgAction , ArgMatches , Command } ;
1110
@@ -18,9 +17,9 @@ const DEFAULT_EVENT_FILE: &str = "events.json";
1817/// Represents the command line arguments of the application.
1918#[ derive( Debug , PartialEq ) ]
2019pub struct Arguments {
21- // The path of the configuration file.
20+ /// The path of the configuration file.
2221 pub config : Option < String > ,
23- // The mode of the application.
22+ /// The mode of the application.
2423 pub mode : Mode ,
2524}
2625
@@ -44,17 +43,23 @@ pub enum Mode {
4443/// Represents the execution of a command.
4544#[ derive( Debug , PartialEq ) ]
4645pub struct BuildCommand {
46+ /// The command arguments to execute.
4747 pub arguments : Vec < String > ,
4848}
4949
50+ /// Represents the semantic output configuration.
5051#[ derive( Debug , PartialEq ) ]
5152pub struct BuildSemantic {
53+ /// The output file path.
5254 pub path : std:: path:: PathBuf ,
55+ /// Whether to append to an existing file.
5356 pub append : bool ,
5457}
5558
59+ /// Represents the build events configuration.
5660#[ derive( Debug , PartialEq ) ]
5761pub struct BuildEvents {
62+ /// The path to the events file.
5863 pub path : std:: path:: PathBuf ,
5964}
6065
@@ -113,7 +118,7 @@ impl TryFrom<&ArgMatches> for BuildCommand {
113118
114119 fn try_from ( matches : & ArgMatches ) -> Result < Self , Self :: Error > {
115120 let arguments: Vec < _ > = matches
116- . get_many ( "COMMAND " )
121+ . get_many ( "BUILD_COMMAND " )
117122 . ok_or ( ParseError :: MissingBuildCommand ) ?
118123 . cloned ( )
119124 . collect ( ) ;
@@ -168,7 +173,7 @@ pub fn cli() -> Command {
168173 Command :: new ( MODE_INTERCEPT_SUBCOMMAND )
169174 . about ( "intercepts command execution" )
170175 . args ( & [
171- arg ! ( <COMMAND > "Build command" )
176+ arg ! ( <BUILD_COMMAND > "Build command" )
172177 . action ( ArgAction :: Append )
173178 . value_terminator ( "--" )
174179 . num_args ( 1 ..)
@@ -196,7 +201,7 @@ pub fn cli() -> Command {
196201 . arg_required_else_help ( false ) ,
197202 )
198203 . args ( & [
199- arg ! ( <COMMAND > "Build command" )
204+ arg ! ( <BUILD_COMMAND > "Build command" )
200205 . action ( ArgAction :: Append )
201206 . value_terminator ( "--" )
202207 . num_args ( 1 ..)
0 commit comments