@@ -12,6 +12,26 @@ use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleC
1212use plib:: PROJECT_NAME ;
1313use std:: path:: { Component , Path , PathBuf } ;
1414
15+ /// realpath -- return resolved canonical path
16+ #[ derive( Parser ) ]
17+ #[ command( version, about) ]
18+ struct Args {
19+ /// Error if the path cannot be resolved
20+ #[ arg( short = 'e' , overrides_with = "_canonicalize_missing" ) ]
21+ canonicalize_existing : bool ,
22+
23+ /// Do not error if the path cannot be resolved (default)
24+ #[ arg( short = 'E' , overrides_with = "canonicalize_existing" ) ]
25+ _canonicalize_missing : bool ,
26+
27+ /// Don't print errors when paths cannot be resolved
28+ #[ arg( short, long) ]
29+ quiet : bool ,
30+
31+ #[ arg( value_name = "PATH" , default_value = "." ) ]
32+ paths : Vec < PathBuf > ,
33+ }
34+
1535/// Returns a normalized path.
1636/// If `must_exist`, returns an error if the path cannot be resolved
1737fn normalize < P : AsRef < Path > > ( path : P ) -> std:: io:: Result < PathBuf > {
@@ -42,26 +62,6 @@ fn normalize<P: AsRef<Path>>(path: P) -> std::io::Result<PathBuf> {
4262 Ok ( out)
4363}
4464
45- /// realpath -- return resolved canonical path
46- #[ derive( Parser ) ]
47- #[ clap( version) ]
48- struct Args {
49- /// Error if the path cannot be resolved
50- #[ clap( short = 'e' , long, overrides_with = "_canonicalize_missing" ) ]
51- canonicalize_existing : bool ,
52-
53- /// Do not error if the path cannot be resolved (default)
54- #[ clap( short = 'E' , overrides_with = "canonicalize_existing" ) ]
55- _canonicalize_missing : bool ,
56-
57- /// Don't print errors when paths cannot be resolved
58- #[ clap( short, long) ]
59- quiet : bool ,
60-
61- #[ clap( value_name = "PATH" , default_value = "." ) ]
62- paths : Vec < PathBuf > ,
63- }
64-
6565fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
6666 let args = Args :: parse ( ) ;
6767
0 commit comments