forked from Drop-OSS/archived-drop-app
Some checks failed
publish / publish-tauri (, ubuntu-22.04) (release) Failing after 14m38s
publish / publish-tauri (, windows-latest) (release) Has been cancelled
publish / publish-tauri (--target aarch64-apple-darwin, macos-14) (release) Has been cancelled
publish / publish-tauri (--target aarch64-unknown-linux-gnu, ubuntu-22.04-arm) (release) Has been cancelled
publish / publish-tauri (--target x86_64-apple-darwin, macos-14) (release) Has been cancelled
* feat: depot api downloads * feat: frontend fixes and experimental webview store * feat: sync downloader * feat: cleanup and fixes * feat: encrypted database and fixed resuming * feat: launch option selector * fix: autostart when no options * fix: clippy * fix: clippy x2 * feat: executor launch * feat: executor launch * feat: not installed error handling * feat: better offline handling * feat: dependency popup * fix: cancelation and resuming issues * feat: dedup by platform * feat: new ui for additional components and fix dl manager clog * feat: auto-queue dependencies * feat: depot scanning and ranking * feat: new library fetching stack * In-app store page (Windows + macOS) (#176) * feat: async store loading * feat: fix overscroll behaviour * fix: query params in server protocol * fix: clippy
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use crate::error::ProcessError;
|
|
|
|
#[derive(Debug)]
|
|
pub struct ParsedCommand {
|
|
pub env: Vec<String>,
|
|
pub command: String,
|
|
pub args: Vec<String>,
|
|
}
|
|
|
|
impl ParsedCommand {
|
|
pub fn parse(raw: String) -> Result<Self, ProcessError> {
|
|
let parts =
|
|
shell_words::split(&raw).map_err(|e| ProcessError::InvalidArguments(e.to_string()))?;
|
|
let args =
|
|
parts
|
|
.iter()
|
|
.position(|v| !v.contains("="))
|
|
.ok_or(ProcessError::InvalidArguments(
|
|
"Cannot parse launch".to_owned(),
|
|
))?;
|
|
let env = &parts[0..args];
|
|
let command = parts[args].clone();
|
|
let args = &parts[(args + 1)..];
|
|
|
|
Ok(Self {
|
|
args: args.to_vec(),
|
|
command,
|
|
env: env.to_vec(),
|
|
})
|
|
}
|
|
|
|
pub fn make_absolute(&mut self, base: PathBuf) {
|
|
self.command = base
|
|
.join(self.command.clone())
|
|
.to_string_lossy()
|
|
.to_string();
|
|
}
|
|
|
|
pub fn reconstruct(self) -> String {
|
|
let mut v = vec![];
|
|
v.extend(self.env);
|
|
v.extend_one(self.command);
|
|
v.extend(self.args);
|
|
v.join(" ")
|
|
}
|
|
}
|
|
|
|
pub struct LaunchParameters(pub String, pub PathBuf);
|