perf: ⚡ clippy fix
This commit is contained in:
parent
9d93e52ac5
commit
674d3c6963
5 changed files with 24 additions and 16 deletions
|
@ -90,7 +90,7 @@ async fn execute(payload: Payload, debug: bool) -> Option<Output> {
|
|||
if debug {
|
||||
eprintln!("Error: Command Execution | {}", err_val);
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +145,10 @@ async fn send(
|
|||
},
|
||||
};
|
||||
|
||||
if debug {
|
||||
report.print();
|
||||
}
|
||||
|
||||
let report = serde_json::json!(report);
|
||||
let result = ws_sender.lock().await.send(report.to_string().into()).await;
|
||||
match result {
|
||||
|
|
|
@ -14,6 +14,7 @@ pub enum Runner {
|
|||
|
||||
impl Runner {
|
||||
fn print(&self) {
|
||||
println!("-------");
|
||||
match self {
|
||||
Runner::Server => println!("Runner = Server"),
|
||||
Runner::Client => println!("Runner = Client"),
|
||||
|
@ -44,6 +45,7 @@ pub struct Config {
|
|||
|
||||
impl Config {
|
||||
pub fn print(&self) {
|
||||
println!("-------");
|
||||
println!("IP = {}", self.ip);
|
||||
println!("Port = {}", self.port);
|
||||
}
|
||||
|
@ -58,6 +60,7 @@ pub struct Payload {
|
|||
|
||||
impl Payload {
|
||||
fn print(&self) {
|
||||
println!("-------");
|
||||
println!("sudo = {}", self.sudo);
|
||||
println!("user = {}", self.user);
|
||||
println!("args = {}", self.args);
|
||||
|
@ -88,7 +91,6 @@ impl Report {
|
|||
}
|
||||
if !self.stderr.is_empty() {
|
||||
println!("Stderr ↓ \n{}", self.stderr);
|
||||
println!("-------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,8 @@ async fn main() {
|
|||
|
||||
match args {
|
||||
Some((runner_mode, config)) => {
|
||||
println!("-------");
|
||||
println!("Runner Mode ↓");
|
||||
runner_mode.print();
|
||||
println!("-------");
|
||||
println!("Config ↓");
|
||||
config.print();
|
||||
println!("-------");
|
||||
|
||||
match runner_mode {
|
||||
RunnerMode::State(Runner::Server, false) => {
|
||||
|
|
|
@ -31,15 +31,21 @@ pub async fn start(config: Config, debug: bool) {
|
|||
match payload_from_input(debug).await {
|
||||
Some(payload) => {
|
||||
if !send(payload, ws_sender, debug).await {
|
||||
if debug {
|
||||
eprintln!("Error: Send");
|
||||
}
|
||||
break;
|
||||
}
|
||||
tokio::spawn(async move {
|
||||
match receive(ws_receiver, debug).await {
|
||||
Some(report) => match serde_json::from_str::<Report>(&report) {
|
||||
if let Some(report) = receive(ws_receiver, debug).await {
|
||||
match serde_json::from_str::<Report>(&report) {
|
||||
Ok(report) => report.print(),
|
||||
Err(_) => {}
|
||||
},
|
||||
None => todo!(),
|
||||
Err(err_val) => {
|
||||
if debug {
|
||||
eprintln!("Error: Deserialize | {}", err_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -87,6 +93,7 @@ async fn establish_connection(
|
|||
}
|
||||
|
||||
async fn payload_from_input(debug: bool) -> Option<Payload> {
|
||||
println!("-------");
|
||||
println!("User");
|
||||
// let user = match get_input(debug) {
|
||||
// Some(input) => input,
|
||||
|
@ -97,7 +104,7 @@ async fn payload_from_input(debug: bool) -> Option<Payload> {
|
|||
match get_input(debug) {
|
||||
Some(input) => {
|
||||
let mut sudo = false;
|
||||
let args = match input.split_once(" ") {
|
||||
let args = match input.split_once(' ') {
|
||||
Some(input_splitted) => {
|
||||
if input_splitted.0 == "sudo" {
|
||||
sudo = true;
|
||||
|
|
|
@ -13,8 +13,8 @@ pub fn take_args() -> Option<(RunnerMode, Config)> {
|
|||
"--server" | "-sv" => runner = Runner::Server,
|
||||
"--client" | "-cl" => runner = Runner::Client,
|
||||
"--debug" | "-d" => debug = true,
|
||||
"--ip" | "-i" => ip = args[i + 1].clone(),
|
||||
"--port" | "-p" => port = args[i + 1].clone(),
|
||||
"--ip" | "-i" => ip.clone_from(&args[i + 1]),
|
||||
"--port" | "-p" => port.clone_from(&args[i + 1]),
|
||||
"--help" | "-h" => {
|
||||
show_help();
|
||||
std::process::exit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue