@@ -14,6 +14,7 @@ pub struct Flags {
1414 pub version_n_continue : bool ,
1515 pub shebang : bool ,
1616 pub sync : bool ,
17+ pub chdir : Option < String > ,
1718}
1819
1920pub struct Args {
@@ -36,9 +37,11 @@ pub fn parse() -> Args {
3637 let mut version_n_continue = false ;
3738 let mut shebang = false ;
3839 let mut sync = false ;
40+ let mut chdir = None ;
3941 let json_latest_v: isize = 2 ;
4042
41- for arg in std:: env:: args ( ) . skip ( 1 ) {
43+ let mut args_iter = std:: env:: args ( ) . skip ( 1 ) ;
44+ while let Some ( arg) = args_iter. next ( ) {
4245 if collecting_args {
4346 args. push ( arg) ;
4447 } else if arg. starts_with ( '+' ) {
@@ -59,6 +62,7 @@ pub fn parse() -> Args {
5962 }
6063 json = Some ( 2 ) ;
6164 }
65+ "--chdir" | "--cd" => chdir = args_iter. next ( ) ,
6266 "--json=v1" => json = Some ( 1 ) ,
6367 "--json=v2" => json = Some ( 2 ) ,
6468 "--silent" => silent = true ,
@@ -105,6 +109,7 @@ pub fn parse() -> Args {
105109 'v' => version_n_continue = true ,
106110 '!' => shebang = true ,
107111 'Q' => mode = Mode :: Query ,
112+ 'C' => chdir = args_iter. next ( ) ,
108113 _ => panic ! ( "unknown argument: -{}" , c) ,
109114 }
110115 }
@@ -127,6 +132,7 @@ pub fn parse() -> Args {
127132 quiet,
128133 version_n_continue,
129134 sync,
135+ chdir,
130136 } ,
131137 }
132138}
0 commit comments