mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-06 15:17:19 +02:00
Finish connect and app command
This commit is contained in:
parent
d80db16973
commit
dbc5c9a82e
@ -1,4 +1,4 @@
|
|||||||
pub(crate) use clap::Command;
|
use clap::{arg, Command};
|
||||||
use winapps::freerdp::freerdp_back::Freerdp;
|
use winapps::freerdp::freerdp_back::Freerdp;
|
||||||
use winapps::RemoteClient;
|
use winapps::RemoteClient;
|
||||||
|
|
||||||
@ -10,6 +10,11 @@ fn cli() -> Command {
|
|||||||
.allow_external_subcommands(true)
|
.allow_external_subcommands(true)
|
||||||
.subcommand(Command::new("check").about("Checks remote connection"))
|
.subcommand(Command::new("check").about("Checks remote connection"))
|
||||||
.subcommand(Command::new("connect").about("Connects to remote"))
|
.subcommand(Command::new("connect").about("Connects to remote"))
|
||||||
|
.subcommand(
|
||||||
|
Command::new("app")
|
||||||
|
.about("Connects to app on remote")
|
||||||
|
.arg(arg!(<APP> "App to open")),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -29,7 +34,13 @@ fn main() {
|
|||||||
println!("Connecting to remote");
|
println!("Connecting to remote");
|
||||||
|
|
||||||
let config = winapps::load_config(None);
|
let config = winapps::load_config(None);
|
||||||
client.run_app(config, "explorer.exe");
|
client.run_app(config, None);
|
||||||
|
}
|
||||||
|
Some(("app", sub_matches)) => {
|
||||||
|
println!("Connecting to app on remote");
|
||||||
|
|
||||||
|
let config = winapps::load_config(None);
|
||||||
|
client.run_app(config, sub_matches.get_one::<String>("APP"));
|
||||||
}
|
}
|
||||||
Some((_, _)) => {
|
Some((_, _)) => {
|
||||||
cli.about("Command not found, try existing ones!")
|
cli.about("Command not found, try existing ones!")
|
||||||
|
@ -19,25 +19,41 @@ pub mod freerdp_back {
|
|||||||
println!("All dependencies found!");
|
println!("All dependencies found!");
|
||||||
println!("Running explorer as test!");
|
println!("Running explorer as test!");
|
||||||
|
|
||||||
self.run_app(config, "explorer.exe");
|
self.run_app(config, Some(&"explorer.exe".to_string()));
|
||||||
|
|
||||||
println!("Test finished!");
|
println!("Test finished!");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_app(&self, config: Config, app: &str) {
|
fn run_app(&self, config: Config, app: Option<&String>) {
|
||||||
let mut xfreerdp = Command::new("xfreerdp");
|
let mut xfreerdp = Command::new("xfreerdp");
|
||||||
xfreerdp.args([
|
match app {
|
||||||
"/app:".to_owned() + app,
|
Some(exe) => {
|
||||||
"/d:".to_owned() + &config.rdp.domain,
|
xfreerdp.args([
|
||||||
"/u:".to_owned() + &config.rdp.username,
|
"/app:".to_owned() + exe,
|
||||||
"/p:".to_owned() + &config.rdp.password,
|
"-wallpaper".to_owned(),
|
||||||
"/v:".to_owned() + &config.rdp.host,
|
"/d:".to_owned() + &config.rdp.domain,
|
||||||
"/dynamic-resolution".to_owned(),
|
"/u:".to_owned() + &config.rdp.username,
|
||||||
"+auto-reconnect".to_owned(),
|
"/p:".to_owned() + &config.rdp.password,
|
||||||
"+clipboard".to_owned(),
|
"/v:".to_owned() + &config.rdp.host,
|
||||||
"+home-drive".to_owned(),
|
"/dynamic-resolution".to_owned(),
|
||||||
"-wallpaper".to_owned(),
|
"+auto-reconnect".to_owned(),
|
||||||
]);
|
"+clipboard".to_owned(),
|
||||||
|
"+home-drive".to_owned(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
xfreerdp.args([
|
||||||
|
"/d:".to_owned() + &config.rdp.domain,
|
||||||
|
"/u:".to_owned() + &config.rdp.username,
|
||||||
|
"/p:".to_owned() + &config.rdp.password,
|
||||||
|
"/v:".to_owned() + &config.rdp.host,
|
||||||
|
"/dynamic-resolution".to_owned(),
|
||||||
|
"+auto-reconnect".to_owned(),
|
||||||
|
"+clipboard".to_owned(),
|
||||||
|
"+home-drive".to_owned(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
xfreerdp.spawn().expect("Freerdp execution failed!");
|
xfreerdp.spawn().expect("Freerdp execution failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ pub mod freerdp;
|
|||||||
pub trait RemoteClient {
|
pub trait RemoteClient {
|
||||||
fn check_depends(&self, config: Config);
|
fn check_depends(&self, config: Config);
|
||||||
|
|
||||||
fn run_app(&self, config: Config, app: &str);
|
fn run_app(&self, config: Config, app: Option<&String>);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(new, Debug, Deserialize, Serialize)]
|
#[derive(new, Debug, Deserialize, Serialize)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user