mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-04 06:07:19 +02:00
fix: merge with upstream/rewrite
This commit is contained in:
commit
984fcc8da7
20
.github/workflows/rust-check.yml
vendored
20
.github/workflows/rust-check.yml
vendored
@ -1,20 +0,0 @@
|
||||
name: Rust Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "rewrite" ]
|
||||
pull_request:
|
||||
branches: [ "rewrite" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: mirlahiji/rust-action@master
|
||||
with:
|
||||
args: cargo fmt -- --check && cargo clippy -- -Dwarnings && cargo test
|
3
.github/workflows/rust-clippy.yml
vendored
3
.github/workflows/rust-clippy.yml
vendored
@ -18,6 +18,9 @@ on:
|
||||
schedule:
|
||||
- cron: '23 2 * * 5'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
rust-clippy-analyze:
|
||||
name: Run rust-clippy analyzing
|
||||
|
@ -1,3 +1,6 @@
|
||||
ci:
|
||||
skip: [clippy, cargo-check]
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.4.0
|
||||
|
@ -9,8 +9,8 @@ import sys
|
||||
def clone_repo():
|
||||
print("📦 Cloning quickemu...")
|
||||
|
||||
print("> git clone --filter=blob:none https://github.com/wimpysworld/quickemu /tmp/quickemu")
|
||||
os.system("git clone --filter=blob:none https://github.com/wimpysworld/quickemu /tmp/quickemu")
|
||||
print("> git clone --filter=blob:none https://github.com/quickemu-project/quickemu /tmp/quickemu")
|
||||
os.system("git clone --filter=blob:none https://github.com/quickemu-project/quickemu /tmp/quickemu")
|
||||
|
||||
print("> mkdir -p ~/.local/bin")
|
||||
os.system("mkdir -p ~/.local/bin")
|
||||
|
@ -1,5 +1,7 @@
|
||||
use clap::Command;
|
||||
use winapps::freerdp::freerdp_back::Freerdp;
|
||||
use winapps::quickemu::{create_vm, run_vm};
|
||||
use winapps::RemoteClient;
|
||||
|
||||
fn cli() -> Command {
|
||||
Command::new("winapps-cli")
|
||||
@ -17,14 +19,20 @@ fn main() {
|
||||
let cli = cli();
|
||||
let matches = cli.clone().get_matches();
|
||||
|
||||
let client: &dyn RemoteClient = &Freerdp {};
|
||||
|
||||
match matches.subcommand() {
|
||||
Some(("check", _)) => {
|
||||
println!("Checking remote connection");
|
||||
|
||||
let _config = winapps::load_config(None);
|
||||
let config = winapps::load_config(None);
|
||||
client.check_depends(config);
|
||||
}
|
||||
Some(("connect", _)) => {
|
||||
println!("Connecting to remote");
|
||||
|
||||
let config = winapps::load_config(None);
|
||||
client.run_app(config, "explorer");
|
||||
}
|
||||
Some(("create-vm", _)) => {
|
||||
println!("Creating windows 10 vm..");
|
||||
|
25
winapps/src/freerdp.rs
Normal file
25
winapps/src/freerdp.rs
Normal file
@ -0,0 +1,25 @@
|
||||
pub mod freerdp_back {
|
||||
use std::process::{Command, Stdio};
|
||||
|
||||
use crate::{Config, RemoteClient};
|
||||
|
||||
pub struct Freerdp {}
|
||||
|
||||
impl RemoteClient for Freerdp {
|
||||
fn check_depends(&self, _config: Config) {
|
||||
let mut xfreerdp = Command::new("xfreerdp");
|
||||
xfreerdp.stdout(Stdio::null());
|
||||
xfreerdp.args(["-h"]);
|
||||
xfreerdp
|
||||
.spawn()
|
||||
.expect("Freerdp execution failed! It needs to be installed!");
|
||||
println!("Freerdp found!");
|
||||
|
||||
println!("Checks success!");
|
||||
}
|
||||
|
||||
fn run_app(&self, _config: Config, _app: &str) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,22 @@
|
||||
pub mod quickemu;
|
||||
|
||||
use derive_new::new;
|
||||
use home::home_dir;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::Write;
|
||||
use std::{
|
||||
env,
|
||||
fs::{self, File},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
pub mod freerdp;
|
||||
|
||||
pub trait RemoteClient {
|
||||
fn check_depends(&self, config: Config);
|
||||
|
||||
fn run_app(&self, config: Config, app: &str);
|
||||
}
|
||||
|
||||
#[derive(new, Debug, Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
#[new(value = "HostConfig::new()")]
|
||||
@ -35,19 +43,9 @@ pub struct RemoteConfig {
|
||||
password: String,
|
||||
}
|
||||
|
||||
pub trait RemoteClient {
|
||||
fn check_depends(&self) -> bool {
|
||||
panic!("Dependency check not implemented!");
|
||||
}
|
||||
|
||||
fn load_config(&self, path: &str);
|
||||
|
||||
fn run_app(&self, app: &str);
|
||||
}
|
||||
|
||||
pub fn load_config(path: Option<&str>) -> Config {
|
||||
let home = home_dir().expect("Could not find the home path!");
|
||||
let default = &format!("{}{}", home.to_str().unwrap(), "/.config/winapps/");
|
||||
let config = env::var("XDG_CONFIG_HOME").expect("Could not find the home path!");
|
||||
let default = &format!("{}{}", config, "/winapps/");
|
||||
let path = Path::new(path.unwrap_or(default));
|
||||
let config = Config::new();
|
||||
|
||||
|
@ -1,11 +1,19 @@
|
||||
use home::home_dir;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use std::process::Command;
|
||||
|
||||
pub(crate) fn get_data_dir() -> PathBuf {
|
||||
pub fn get_data_dir() -> PathBuf {
|
||||
let home = home_dir().expect("Could not find the home path!");
|
||||
let data_dir = home.join(".local/share/winapps");
|
||||
|
||||
let data_dir = match env::var("XDG_DATA_HOME") {
|
||||
Ok(dir) => PathBuf::from(dir).join("winapps"),
|
||||
Err(_) => {
|
||||
println!("Couldn't read XDG_DATA_HOME, falling back to ~/.local/share");
|
||||
home.join(".local/share/winapps")
|
||||
}
|
||||
};
|
||||
|
||||
if !data_dir.exists() {
|
||||
let dir = data_dir.clone();
|
||||
@ -48,8 +56,7 @@ pub fn run_vm() {
|
||||
|
||||
let output = match Command::new("quickemu")
|
||||
.current_dir(data_dir)
|
||||
.arg("--vm")
|
||||
.arg("windows-10-22H2.conf")
|
||||
.args(["--vm", "windows-10-22H2.conf", "--display", "none"])
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait_with_output()
|
||||
|
Loading…
x
Reference in New Issue
Block a user