mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 01:26:04 -08:00
Auto update (w/ cli)
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -62,6 +62,7 @@ use system::logging;
|
||||
enum Task {
|
||||
Activity(NextActivity),
|
||||
ImportTheme(PathBuf),
|
||||
InstallUpdate,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
@@ -84,6 +85,12 @@ struct Args {
|
||||
quiet: bool,
|
||||
#[argh(option, short = 't', description = "import specified theme")]
|
||||
theme: Option<String>,
|
||||
#[argh(
|
||||
switch,
|
||||
short = 'u',
|
||||
description = "update termscp to the latest version"
|
||||
)]
|
||||
update: bool,
|
||||
#[argh(
|
||||
option,
|
||||
short = 'T',
|
||||
@@ -177,6 +184,9 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
|
||||
if let Some(theme) = args.theme {
|
||||
run_opts.task = Task::ImportTheme(PathBuf::from(theme));
|
||||
}
|
||||
if args.update {
|
||||
run_opts.task = Task::InstallUpdate;
|
||||
}
|
||||
// @! Ordinary mode
|
||||
// Remote argument
|
||||
if let Some(remote) = args.positional.get(0) {
|
||||
@@ -256,6 +266,16 @@ fn run(mut run_opts: RunOpts) -> i32 {
|
||||
1
|
||||
}
|
||||
},
|
||||
Task::InstallUpdate => match support::install_update() {
|
||||
Ok(msg) => {
|
||||
println!("{}", msg);
|
||||
0
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Could not install update: {}", err);
|
||||
1
|
||||
}
|
||||
},
|
||||
Task::Activity(activity) => {
|
||||
// Get working directory
|
||||
let wrkdir: PathBuf = match env::current_dir() {
|
||||
|
||||
Reference in New Issue
Block a user