@@ -2,15 +2,10 @@ use std::fs;
22use std:: io:: { self , Write } ;
33use std:: path:: PathBuf ;
44
5- extern crate clap;
6- use clap:: {
7- crate_authors, crate_description, crate_name, crate_version, App , AppSettings , Arg , ArgGroup ,
8- Values ,
9- } ;
10-
11- extern crate colored;
125use colored:: * ;
136
7+ mod cmd_line;
8+
149// Load the AsciiDoc templates at build time
1510const ASSEMBLY_TEMPLATE : & str = include_str ! ( "../templates/assembly.adoc" ) ;
1611const CONCEPT_TEMPLATE : & str = include_str ! ( "../templates/concept.adoc" ) ;
@@ -71,86 +66,7 @@ struct Options {
7166}
7267
7368fn main ( ) {
74- // Define command-line options
75- let cmdline_args = App :: new ( crate_name ! ( ) )
76- . version ( crate_version ! ( ) )
77- . author ( crate_authors ! ( ) )
78- . about ( crate_description ! ( ) )
79- // If no arguments are provided, print help
80- . setting ( AppSettings :: ArgRequiredElseHelp )
81- . arg (
82- Arg :: with_name ( "assembly" )
83- . short ( "a" )
84- . long ( "assembly" )
85- . takes_value ( true )
86- . value_name ( "title" )
87- . multiple ( true )
88- . help ( "Create an assembly file" ) ,
89- )
90- . arg (
91- Arg :: with_name ( "include-in" )
92- . short ( "i" )
93- . long ( "include-in" )
94- . takes_value ( true )
95- . value_name ( "title" )
96- . multiple ( false )
97- . help ( "Create an assembly that includes the other specified modules" ) ,
98- )
99- . arg (
100- Arg :: with_name ( "concept" )
101- . short ( "c" )
102- . long ( "concept" )
103- . takes_value ( true )
104- . value_name ( "title" )
105- . multiple ( true )
106- . help ( "Create a concept module" ) ,
107- )
108- . arg (
109- Arg :: with_name ( "procedure" )
110- . short ( "p" )
111- . long ( "procedure" )
112- . takes_value ( true )
113- . value_name ( "title" )
114- . multiple ( true )
115- . help ( "Create a procedure module" ) ,
116- )
117- . arg (
118- Arg :: with_name ( "reference" )
119- . short ( "r" )
120- . long ( "reference" )
121- . takes_value ( true )
122- . value_name ( "title" )
123- . multiple ( true )
124- . help ( "Create a reference module" ) ,
125- )
126- // This group ensures that at least one of the assembly or module inputs is present
127- . group (
128- ArgGroup :: with_name ( "modules" )
129- . args ( & [ "assembly" , "concept" , "procedure" , "reference" ] )
130- . required ( true )
131- . multiple ( true ) ,
132- )
133- . arg (
134- Arg :: with_name ( "no-comments" )
135- . short ( "C" )
136- . long ( "no-comments" )
137- . help ( "Generate the file without any comments" ) ,
138- )
139- . arg (
140- Arg :: with_name ( "no-prefixes" )
141- . short ( "P" )
142- . long ( "no-prefixes" )
143- . help ( "Do not use module type prefixes (e.g. `proc_`) in file names" ) ,
144- )
145- . arg (
146- Arg :: with_name ( "target-dir" )
147- . short ( "-T" )
148- . long ( "target-dir" )
149- . takes_value ( true )
150- . value_name ( "directory" )
151- . help ( "Save the generated files in this directory" ) ,
152- )
153- . get_matches ( ) ;
69+ let cmdline_args = cmd_line:: get_args ( ) ;
15470
15571 // Set current options based on the command-line options
15672 let options = Options {
@@ -210,7 +126,7 @@ fn main() {
210126
211127/// Process all titles that have been specified on the command line and that belong to a single
212128/// module type.
213- fn process_module_type ( titles : Values , module_type_str : & str , options : & Options ) -> Vec < Module > {
129+ fn process_module_type ( titles : clap :: Values , module_type_str : & str , options : & Options ) -> Vec < Module > {
214130 let mut modules_from_type = Vec :: new ( ) ;
215131
216132 for title in titles {
0 commit comments