File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 11use clap:: { Parser , ValueEnum } ;
22
3- use std:: { env:: current_dir, path:: PathBuf } ;
3+ use std:: { env:: current_dir, fs , path:: PathBuf } ;
44
55#[ derive( Debug , Parser ) ]
66#[ command( version = "0.1.0" ) ]
@@ -39,19 +39,21 @@ pub enum Mode {
3939
4040impl Cli {
4141 pub fn dir ( & self ) -> PathBuf {
42- self . dir
43- . as_ref ( )
44- . cloned ( )
45- . or_else ( || current_dir ( ) . ok ( ) )
46- . expect ( "Failed to get DIR" )
42+ let dir = match & self . dir {
43+ Some ( dir) => fs:: canonicalize ( dir) ,
44+ None => current_dir ( ) ,
45+ } ;
46+
47+ dir. expect ( "Failed to get DIR" )
4748 }
4849
4950 pub fn target ( & self ) -> PathBuf {
50- self . target
51- . as_ref ( )
52- . cloned ( )
53- . or_else ( || Some ( self . dir ( ) . parent ( ) ?. to_path_buf ( ) ) )
54- . expect ( "Failed to get TARGET" )
51+ let target = match & self . target {
52+ Some ( dir) => fs:: canonicalize ( dir) . ok ( ) ,
53+ None => self . dir ( ) . parent ( ) . map ( |d| d. to_path_buf ( ) ) ,
54+ } ;
55+
56+ target. expect ( "Failed to get TARGET" )
5557 }
5658
5759 pub fn parsed ( ) -> Self {
You can’t perform that action at this time.
0 commit comments