File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -48,3 +48,6 @@ features = ["precommit-hook", "user-hooks"]
4848
4949[features ]
5050pym = [" pyo3" ]
51+
52+ [target .'cfg(target_family = "unix")' .dependencies ]
53+ nix = " 0.17.0"
Original file line number Diff line number Diff line change @@ -9,8 +9,24 @@ use crate::{
99} ;
1010use clap:: { crate_name, crate_version, App , AppSettings } ;
1111
12+ /// This should be called before calling any cli method or printing any output.
13+ pub fn reset_signal_pipe_handler ( ) -> Result < ( ) , ( ) > {
14+ #[ cfg( target_family = "unix" ) ]
15+ {
16+ use nix:: sys:: signal;
17+
18+ unsafe {
19+ signal:: signal ( signal:: Signal :: SIGPIPE , signal:: SigHandler :: SigDfl )
20+ . map_err ( |e| println ! ( "{:?}" , e) ) ?;
21+ }
22+ }
23+
24+ Ok ( ( ) )
25+ }
26+
1227/// Get maches
1328pub async fn main ( ) -> Result < ( ) , Error > {
29+ let _ = reset_signal_pipe_handler ( ) ;
1430 let m = App :: new ( crate_name ! ( ) )
1531 . version ( crate_version ! ( ) )
1632 . about ( "May the Code be with You 👻" )
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ use super::Command;
3737use crate :: { cache:: Cache , err:: Error , helper:: Digit } ;
3838use async_trait:: async_trait;
3939use clap:: { App , Arg , ArgMatches , SubCommand } ;
40+ use std:: io:: { self , Write } ;
4041/// Abstract `list` command
4142///
4243/// ## handler
@@ -168,9 +169,8 @@ impl Command for ListCommand {
168169 ps. retain ( |x| x. name . contains ( & keyword) ) ;
169170 }
170171
171- for p in & ps {
172- println ! ( "{}" , p) ;
173- }
172+ let out: Vec < String > = ps. iter ( ) . map ( ToString :: to_string) . collect ( ) ;
173+ io:: stdout ( ) . write_all ( out. join ( "\n " ) . as_bytes ( ) ) ?;
174174
175175 // one more thing, filter stat
176176 if m. is_present ( "stat" ) {
You can’t perform that action at this time.
0 commit comments