@@ -4,7 +4,7 @@ use std::env;
44use std:: fs:: read;
55use std:: path:: PathBuf ;
66use std:: process:: exit;
7- use std:: io:: { self , IsTerminal , Read } ;
7+ use std:: io:: { self , Read } ;
88
99use clap:: Parser ;
1010use reqwest:: blocking:: { Client , RequestBuilder } ;
@@ -59,40 +59,34 @@ fn main() {
5959 let mut exec_file: Vec < u8 > = Vec :: new ( ) ;
6060 let mut file_path = PathBuf :: new ( ) ;
6161
62- if !io:: stdin ( ) . is_terminal ( )
63- && ( io:: stderr ( ) . is_terminal ( ) || io:: stdout ( ) . is_terminal ( ) || args. stdin ) {
64- args. stdin = true ;
62+ if args. stdin {
6563 io:: stdin ( ) . lock ( ) . read_to_end ( & mut exec_file) . unwrap ( ) ;
66- } else {
67- if args. url . is_some ( ) {
68- let client = Client :: builder ( ) ;
69-
70- #[ cfg( target_os = "windows" ) ]
71- let client = client. use_rustls_tls ( ) ;
72-
73- let client = client
74- . danger_accept_invalid_certs ( true )
75- . timeout ( None )
76- . build ( )
77- . unwrap ( ) ;
78-
79- let req: RequestBuilder ;
80- let url = args. url . as_ref ( ) . unwrap ( ) ;
81- if args. post {
82- req = client. post ( url)
83- } else {
84- req = client. get ( url)
85- }
86- exec_file = req. send ( ) . unwrap ( ) . bytes ( ) . unwrap ( ) . to_vec ( ) ;
87- drop ( client)
64+ } else if args. url . is_some ( ) {
65+ let client = Client :: builder ( ) ;
66+
67+ #[ cfg( target_os = "windows" ) ]
68+ let client = client. use_rustls_tls ( ) ;
69+
70+ let client = client
71+ . danger_accept_invalid_certs ( true )
72+ . timeout ( None )
73+ . build ( )
74+ . unwrap ( ) ;
75+
76+ let req: RequestBuilder ;
77+ let url = args. url . as_ref ( ) . unwrap ( ) ;
78+ if args. post {
79+ req = client. post ( url)
8880 } else {
89- if args. exec_args . is_empty ( ) {
90- eprintln ! ( "Specify the path to the binary file!" ) ;
91- exit ( 1 )
92- } else {
93- file_path = PathBuf :: from ( args. exec_args . remove ( 0 ) )
94- }
81+ req = client. get ( url)
9582 }
83+ exec_file = req. send ( ) . unwrap ( ) . bytes ( ) . unwrap ( ) . to_vec ( ) ;
84+ drop ( client)
85+ } else if !args. exec_args . is_empty ( ) {
86+ file_path = PathBuf :: from ( args. exec_args . remove ( 0 ) ) ;
87+ } else {
88+ eprintln ! ( "Specify the path to the binary file!" ) ;
89+ exit ( 1 )
9690 }
9791
9892 if !file_path. to_str ( ) . unwrap ( ) . is_empty ( ) && exec_file. is_empty ( ) {
0 commit comments