11use crate :: errors:: KeeperError ;
22use colored:: Colorize ;
3- use error_stack:: { IntoReport , Result , ResultExt } ;
3+ use error_stack:: { IntoReport , Report , ResultExt } ;
44use std:: collections:: HashMap ;
55use std:: io;
66use std:: io:: { Read , Write } ;
@@ -39,11 +39,11 @@ pub fn run_command(
3939 command_name : & str ,
4040 args : & [ & str ] ,
4141 verbose : bool ,
42- ) -> Result < CommandOutput , KeeperError > {
42+ ) -> Result < CommandOutput , Report < KeeperError > > {
4343 run_command_with_env_vars ( command_name, args, & None , & None , verbose)
4444}
4545
46- pub fn run_command_line ( command_line : & str , verbose : bool ) -> Result < CommandOutput , KeeperError > {
46+ pub fn run_command_line ( command_line : & str , verbose : bool ) -> Result < CommandOutput , Report < KeeperError > > {
4747 let command_and_args = shlex:: split ( command_line) . unwrap ( ) ;
4848 // command line contains pipe or not
4949 if command_and_args
@@ -66,17 +66,15 @@ pub fn run_command_line(command_line: &str, verbose: bool) -> Result<CommandOutp
6666 . bold( )
6767 . red( )
6868 ) ;
69- Err ( KeeperError :: CommandNotFound (
70- command_name. to_string ( )
71- ) . into_report ( ) )
69+ Err ( KeeperError :: CommandNotFound ( command_name. to_string ( ) ) . into_report ( ) )
7270 }
7371}
7472
7573pub fn run_command_line_from_stdin (
7674 command_line : & str ,
7775 input : & str ,
7876 verbose : bool ,
79- ) -> Result < CommandOutput , KeeperError > {
77+ ) -> Result < CommandOutput , Report < KeeperError > > {
8078 let command_and_args = shlex:: split ( command_line) . unwrap ( ) ;
8179 let command_name = & command_and_args[ 0 ] ;
8280 let args: Vec < & str > = if command_and_args. len ( ) > 1 {
@@ -117,9 +115,7 @@ pub fn run_command_line_from_stdin(
117115 . bold( )
118116 . red( )
119117 ) ;
120- Err ( KeeperError :: CommandNotFound (
121- command_name. to_string ( )
122- ) . into_report ( ) )
118+ Err ( KeeperError :: CommandNotFound ( command_name. to_string ( ) ) . into_report ( ) )
123119 }
124120}
125121
@@ -129,7 +125,7 @@ pub fn run_command_with_env_vars(
129125 working_dir : & Option < String > ,
130126 env_vars : & Option < HashMap < String , String > > ,
131127 verbose : bool ,
132- ) -> Result < CommandOutput , KeeperError > {
128+ ) -> Result < CommandOutput , Report < KeeperError > > {
133129 let mut command = Command :: new ( command_name) ;
134130 command. envs ( std:: env:: vars ( ) ) ;
135131 if args. len ( ) > 0 {
@@ -161,7 +157,7 @@ pub fn run_command_with_env_vars(
161157pub fn run_command_by_shell (
162158 command_line : & str ,
163159 verbose : bool ,
164- ) -> Result < CommandOutput , KeeperError > {
160+ ) -> Result < CommandOutput , Report < KeeperError > > {
165161 let mut command = if cfg ! ( target_os = "windows" ) {
166162 Command :: new ( "cmd" )
167163 } else {
@@ -186,7 +182,7 @@ pub fn run_command_by_shell(
186182 . change_context ( KeeperError :: FailedToRunTasks ( format ! ( "{:?}" , command) ) )
187183}
188184
189- pub fn intercept_output ( command : & mut Command ) -> Result < CommandOutput , KeeperError > {
185+ pub fn intercept_output ( command : & mut Command ) -> Result < CommandOutput , Report < KeeperError > > {
190186 let mut child = command
191187 . stdin ( Stdio :: inherit ( ) )
192188 . stdout ( Stdio :: piped ( ) )
@@ -244,7 +240,7 @@ pub fn intercept_output(command: &mut Command) -> Result<CommandOutput, KeeperEr
244240 } )
245241}
246242
247- pub fn capture_command_output ( command_name : & str , args : & [ & str ] ) -> Result < Output , KeeperError > {
243+ pub fn capture_command_output ( command_name : & str , args : & [ & str ] ) -> Result < Output , Report < KeeperError > > {
248244 let mut command = Command :: new ( command_name) ;
249245 if args. len ( ) > 0 {
250246 command. args ( args) ;
0 commit comments