@@ -84,6 +84,27 @@ const CMD_SCRIPT: &'static str = "script";
8484const CMD_SCRIPT_SHOW : & ' static str = "show" ;
8585const CMD_SCRIPT_EDIT : & ' static str = "edit" ;
8686
87+ const CMD_INDEX : & ' static str = "index" ;
88+
89+ const CMD_LS : & ' static str = "ls" ;
90+
91+ const CMD_EXTRACT : & ' static str = "extract" ;
92+
93+ const CMD_POV : & ' static str = "pov" ;
94+ const CMD_POV_EXTRACT : & ' static str = "extract" ;
95+
96+ const CMD_NEW : & ' static str = "new" ;
97+
98+ const CMD_INFO : & ' static str = "info" ;
99+
100+ const CMD_EXTRACTVBS : & ' static str = "extractvbs" ;
101+
102+ const CMD_IMPORTVBS : & ' static str = "importvbs" ;
103+
104+ const CMD_VERIFY : & ' static str = "verify" ;
105+
106+ const CMD_ASSEMBLE : & ' static str = "assemble" ;
107+
87108fn main ( ) -> ExitCode {
88109 fixprint:: safe_main ( run)
89110}
@@ -96,7 +117,7 @@ fn run() -> io::Result<ExitCode> {
96117
97118fn handle_command ( matches : ArgMatches ) -> io:: Result < ExitCode > {
98119 match matches. subcommand ( ) {
99- Some ( ( "info" , sub_matches) ) => {
120+ Some ( ( CMD_INFO , sub_matches) ) => {
100121 let path = sub_matches. get_one :: < String > ( "VPXPATH" ) . map ( |s| s. as_str ( ) ) ;
101122 let path = path. unwrap_or ( "" ) ;
102123 let expanded_path = expand_path ( path) ?;
@@ -185,7 +206,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
185206 }
186207 }
187208 }
188- Some ( ( "index" , sub_matches) ) => {
209+ Some ( ( CMD_INDEX , sub_matches) ) => {
189210 let recursive = sub_matches. get_flag ( "RECURSIVE" ) ;
190211 let path = sub_matches
191212 . get_one :: < String > ( "VPXROOTPATH" )
@@ -262,7 +283,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
262283 }
263284 _ => unreachable ! ( ) ,
264285 } ,
265- Some ( ( "ls" , sub_matches) ) => {
286+ Some ( ( CMD_LS , sub_matches) ) => {
266287 let path = sub_matches
267288 . get_one :: < String > ( "VPXPATH" )
268289 . map ( |s| s. as_str ( ) )
@@ -272,7 +293,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
272293 ls ( expanded_path. as_ref ( ) ) ?;
273294 Ok ( ExitCode :: SUCCESS )
274295 }
275- Some ( ( "extract" , sub_matches) ) => {
296+ Some ( ( CMD_EXTRACT , sub_matches) ) => {
276297 let yes = sub_matches. get_flag ( "FORCE" ) ;
277298 let paths: Vec < & str > = sub_matches
278299 . get_many :: < String > ( "VPXPATH" )
@@ -290,7 +311,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
290311 }
291312 Ok ( ExitCode :: SUCCESS )
292313 }
293- Some ( ( "extractvbs" , sub_matches) ) => {
314+ Some ( ( CMD_EXTRACTVBS , sub_matches) ) => {
294315 let overwrite = sub_matches. get_flag ( "OVERWRITE" ) ;
295316 let paths: Vec < & str > = sub_matches
296317 . get_many :: < String > ( "VPXPATH" )
@@ -312,7 +333,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
312333 }
313334 Ok ( ExitCode :: SUCCESS )
314335 }
315- Some ( ( "importvbs" , sub_matches) ) => {
336+ Some ( ( CMD_IMPORTVBS , sub_matches) ) => {
316337 let path: & str = sub_matches. get_one :: < String > ( "VPXPATH" ) . unwrap ( ) . as_str ( ) ;
317338 let expanded_path = PathBuf :: from ( expand_path ( path) ?) ;
318339 match importvbs ( & expanded_path, None ) {
@@ -328,7 +349,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
328349 }
329350 }
330351
331- Some ( ( "verify" , sub_matches) ) => {
352+ Some ( ( CMD_VERIFY , sub_matches) ) => {
332353 let paths: Vec < & str > = sub_matches
333354 . get_many :: < String > ( "VPXPATH" )
334355 . unwrap_or_default ( )
@@ -349,7 +370,7 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
349370 }
350371 Ok ( ExitCode :: SUCCESS )
351372 }
352- Some ( ( "new" , sub_matches) ) => {
373+ Some ( ( CMD_NEW , sub_matches) ) => {
353374 let path = {
354375 let this = sub_matches. get_one :: < String > ( "VPXPATH" ) . map ( |v| v. as_str ( ) ) ;
355376 match this {
@@ -429,8 +450,8 @@ fn handle_command(matches: ArgMatches) -> io::Result<ExitCode> {
429450 } ,
430451 _ => unreachable ! ( ) ,
431452 } ,
432- Some ( ( "pov" , sub_matches) ) => match sub_matches. subcommand ( ) {
433- Some ( ( "extract" , sub_matches) ) => {
453+ Some ( ( CMD_POV , sub_matches) ) => match sub_matches. subcommand ( ) {
454+ Some ( ( CMD_POV_EXTRACT , sub_matches) ) => {
434455 let paths: Vec < & str > = sub_matches
435456 . get_many :: < String > ( "VPXPATH" )
436457 . unwrap_or_default ( )
@@ -506,7 +527,7 @@ fn build_command() -> Command {
506527 )
507528 )
508529 . subcommand (
509- Command :: new ( "index" )
530+ Command :: new ( CMD_INDEX )
510531 . about ( "Indexes a directory of vpx files" )
511532 . arg (
512533 Arg :: new ( "RECURSIVE" )
@@ -543,15 +564,15 @@ fn build_command() -> Command {
543564 )
544565 )
545566 . subcommand (
546- Command :: new ( "ls" )
567+ Command :: new ( CMD_LS )
547568 . about ( "Show a vpx file content" )
548569 . arg (
549570 arg ! ( <VPXPATH > "The path to the vpx file" )
550571 . required ( true ) ,
551572 ) ,
552573 )
553574 . subcommand (
554- Command :: new ( "extract" )
575+ Command :: new ( CMD_EXTRACT )
555576 . about ( "Extracts a vpx file" )
556577 . arg (
557578 Arg :: new ( "FORCE" )
@@ -567,7 +588,7 @@ fn build_command() -> Command {
567588 ) ,
568589 )
569590 . subcommand (
570- Command :: new ( "extractvbs" )
591+ Command :: new ( CMD_EXTRACTVBS )
571592 . about ( "Extracts the vbs from a vpx file next to it" )
572593 . arg (
573594 Arg :: new ( "OVERWRITE" )
@@ -584,7 +605,7 @@ fn build_command() -> Command {
584605 ) ,
585606 )
586607 . subcommand (
587- Command :: new ( "importvbs" )
608+ Command :: new ( CMD_IMPORTVBS )
588609 . about ( "Imports the vbs next to it into a vpx file" )
589610 . arg (
590611 arg ! ( <VPXPATH > "The path(s) to the vpx file(s)" )
@@ -593,7 +614,7 @@ fn build_command() -> Command {
593614 ) ,
594615 )
595616 . subcommand (
596- Command :: new ( "verify" )
617+ Command :: new ( CMD_VERIFY )
597618 . about ( "Verify the structure of a vpx file" )
598619 . arg (
599620 arg ! ( <VPXPATH > "The path(s) to the vpx file(s)" )
@@ -602,10 +623,10 @@ fn build_command() -> Command {
602623 ) ,
603624 )
604625 . subcommand (
605- Command :: new ( "pov" )
626+ Command :: new ( CMD_POV )
606627 . subcommand_required ( true )
607628 . about ( "Point of view file (pov) related commands" )
608- . subcommand ( Command :: new ( "extract" )
629+ . subcommand ( Command :: new ( CMD_POV_EXTRACT )
609630 . about ( "Extracts a the pov file from a vpx file" )
610631 . arg (
611632 arg ! ( <VPXPATH > "The path(s) to the vpx file(s)" )
@@ -615,12 +636,12 @@ fn build_command() -> Command {
615636 )
616637 )
617638 . subcommand (
618- Command :: new ( "assemble" )
639+ Command :: new ( CMD_ASSEMBLE )
619640 . about ( "Assembles a vpx file" )
620641 . arg ( arg ! ( <DIRPATH > "The path to the vpx structure" ) . required ( true ) ) ,
621642 )
622643 . subcommand (
623- Command :: new ( "new" )
644+ Command :: new ( CMD_NEW )
624645 . about ( "Creates a minimal empty new vpx file" )
625646 . arg ( arg ! ( <VPXPATH > "The path(s) to the vpx file" ) . required ( true ) ) ,
626647 )
0 commit comments