mirror of
https://github.com/veeso/termscp.git
synced 2026-09-26 05:51:20 -07:00
fix: better main runner
This commit is contained in:
Generated
+3
-2
@@ -1822,11 +1822,12 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "open"
|
name = "open"
|
||||||
version = "4.1.0"
|
version = "5.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d16814a067484415fda653868c9be0ac5f2abd2ef5d951082a5f2fe1b3662944"
|
checksum = "cfabf1927dce4d6fdf563d63328a0a506101ced3ec780ca2135747336c98cef8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"is-wsl",
|
"is-wsl",
|
||||||
|
"libc",
|
||||||
"pathdiff",
|
"pathdiff",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
+27
-12
@@ -5,7 +5,13 @@ description = "termscp is a feature rich terminal file transfer and explorer wit
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
homepage = "https://termscp.veeso.dev"
|
homepage = "https://termscp.veeso.dev"
|
||||||
include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
|
include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
|
||||||
keywords = ["scp-client", "sftp-client", "ftp-client", "winscp", "command-line-utility"]
|
keywords = [
|
||||||
|
"scp-client",
|
||||||
|
"sftp-client",
|
||||||
|
"ftp-client",
|
||||||
|
"winscp",
|
||||||
|
"command-line-utility",
|
||||||
|
]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "termscp"
|
name = "termscp"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
@@ -46,14 +52,23 @@ lazy_static = "^1.4"
|
|||||||
log = "^0.4"
|
log = "^0.4"
|
||||||
magic-crypt = "^3.1"
|
magic-crypt = "^3.1"
|
||||||
notify = "^4.0"
|
notify = "^4.0"
|
||||||
notify-rust = { version = "^4.5", default-features = false, features = [ "d" ] }
|
notify-rust = { version = "^4.5", default-features = false, features = ["d"] }
|
||||||
open = "^4.0"
|
open = "^5.0"
|
||||||
rand = "^0.8.5"
|
rand = "^0.8.5"
|
||||||
remotefs = "^0.2.0"
|
remotefs = "^0.2.0"
|
||||||
remotefs-aws-s3 = { version = "^0.2.1", default-features = false, features = [ "find", "rustls" ] }
|
remotefs-aws-s3 = { version = "^0.2.1", default-features = false, features = [
|
||||||
|
"find",
|
||||||
|
"rustls",
|
||||||
|
] }
|
||||||
rpassword = "^7.0"
|
rpassword = "^7.0"
|
||||||
self_update = { version = "^0.36", default-features = false, features = [ "rustls", "archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate" ] }
|
self_update = { version = "^0.36", default-features = false, features = [
|
||||||
serde = { version = "^1", features = [ "derive" ] }
|
"rustls",
|
||||||
|
"archive-tar",
|
||||||
|
"archive-zip",
|
||||||
|
"compression-flate2",
|
||||||
|
"compression-zip-deflate",
|
||||||
|
] }
|
||||||
|
serde = { version = "^1", features = ["derive"] }
|
||||||
simplelog = "^0.12"
|
simplelog = "^0.12"
|
||||||
ssh2-config = "^0.2"
|
ssh2-config = "^0.2"
|
||||||
tempfile = "^3.4"
|
tempfile = "^3.4"
|
||||||
@@ -74,9 +89,9 @@ serial_test = "^2.0"
|
|||||||
cfg_aliases = "0.1"
|
cfg_aliases = "0.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "with-keyring" ]
|
default = ["with-keyring"]
|
||||||
github-actions = [ ]
|
github-actions = []
|
||||||
with-keyring = [ "keyring" ]
|
with-keyring = ["keyring"]
|
||||||
|
|
||||||
[target."cfg(not(target_os = \"macos\"))"]
|
[target."cfg(not(target_os = \"macos\"))"]
|
||||||
[target."cfg(not(target_os = \"macos\"))".dependencies]
|
[target."cfg(not(target_os = \"macos\"))".dependencies]
|
||||||
@@ -84,13 +99,13 @@ remotefs-smb = "^0.2"
|
|||||||
|
|
||||||
[target."cfg(target_family = \"windows\")"]
|
[target."cfg(target_family = \"windows\")"]
|
||||||
[target."cfg(target_family = \"windows\")".dependencies]
|
[target."cfg(target_family = \"windows\")".dependencies]
|
||||||
remotefs-ftp = { version = "^0.1.2", features = [ "native-tls" ] }
|
remotefs-ftp = { version = "^0.1.2", features = ["native-tls"] }
|
||||||
remotefs-ssh = "^0.2"
|
remotefs-ssh = "^0.2"
|
||||||
|
|
||||||
[target."cfg(target_family = \"unix\")"]
|
[target."cfg(target_family = \"unix\")"]
|
||||||
[target."cfg(target_family = \"unix\")".dependencies]
|
[target."cfg(target_family = \"unix\")".dependencies]
|
||||||
remotefs-ftp = { version = "^0.1.2", features = [ "vendored", "native-tls" ] }
|
remotefs-ftp = { version = "^0.1.2", features = ["vendored", "native-tls"] }
|
||||||
remotefs-ssh = { version = "^0.2", features = [ "ssh2-vendored" ] }
|
remotefs-ssh = { version = "^0.2", features = ["ssh2-vendored"] }
|
||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
+62
-53
@@ -14,9 +14,9 @@ extern crate log;
|
|||||||
extern crate magic_crypt;
|
extern crate magic_crypt;
|
||||||
|
|
||||||
// External libs
|
// External libs
|
||||||
use std::env;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use std::{env, path::Path};
|
||||||
|
|
||||||
// Include
|
// Include
|
||||||
mod activity_manager;
|
mod activity_manager;
|
||||||
@@ -139,59 +139,68 @@ fn parse_remote_address(remote: &str) -> Result<FileTransferParams, String> {
|
|||||||
/// Run task and return rc
|
/// Run task and return rc
|
||||||
fn run(run_opts: RunOpts) -> i32 {
|
fn run(run_opts: RunOpts) -> i32 {
|
||||||
match run_opts.task {
|
match run_opts.task {
|
||||||
Task::ImportTheme(theme) => match support::import_theme(theme.as_path()) {
|
Task::ImportTheme(theme) => run_import_theme(&theme),
|
||||||
Ok(_) => {
|
Task::InstallUpdate => run_install_update(),
|
||||||
println!("Theme has been successfully imported!");
|
Task::Activity(activity) => run_activity(activity, run_opts.ticks, run_opts.remote),
|
||||||
0
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
|
||||||
eprintln!("{err}");
|
fn run_import_theme(theme: &Path) -> i32 {
|
||||||
1
|
match support::import_theme(theme) {
|
||||||
}
|
Ok(_) => {
|
||||||
},
|
println!("Theme has been successfully imported!");
|
||||||
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() {
|
|
||||||
Ok(dir) => dir,
|
|
||||||
Err(_) => PathBuf::from("/"),
|
|
||||||
};
|
|
||||||
// Create activity manager (and context too)
|
|
||||||
let mut manager: ActivityManager =
|
|
||||||
match ActivityManager::new(wrkdir.as_path(), run_opts.ticks) {
|
|
||||||
Ok(m) => m,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Could not start activity manager: {err}");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Set file transfer params if set
|
|
||||||
match run_opts.remote {
|
|
||||||
Remote::Bookmark(BookmarkParams { name, password }) => {
|
|
||||||
if let Err(err) = manager.resolve_bookmark_name(&name, password.as_deref()) {
|
|
||||||
eprintln!("{err}");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Remote::Host(HostParams { params, password }) => {
|
|
||||||
if let Err(err) = manager.set_filetransfer_params(params, password.as_deref()) {
|
|
||||||
eprintln!("{err}");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Remote::None => {}
|
|
||||||
}
|
|
||||||
manager.run(activity);
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("{err}");
|
||||||
|
1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn run_install_update() -> i32 {
|
||||||
|
match support::install_update() {
|
||||||
|
Ok(msg) => {
|
||||||
|
println!("{msg}");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Could not install update: {err}");
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run_activity(activity: NextActivity, ticks: Duration, remote: Remote) -> i32 {
|
||||||
|
// Get working directory
|
||||||
|
let wrkdir: PathBuf = match env::current_dir() {
|
||||||
|
Ok(dir) => dir,
|
||||||
|
Err(_) => PathBuf::from("/"),
|
||||||
|
};
|
||||||
|
// Create activity manager (and context too)
|
||||||
|
let mut manager: ActivityManager = match ActivityManager::new(wrkdir.as_path(), ticks) {
|
||||||
|
Ok(m) => m,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Could not start activity manager: {err}");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Set file transfer params if set
|
||||||
|
match remote {
|
||||||
|
Remote::Bookmark(BookmarkParams { name, password }) => {
|
||||||
|
if let Err(err) = manager.resolve_bookmark_name(&name, password.as_deref()) {
|
||||||
|
eprintln!("{err}");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Remote::Host(HostParams { params, password }) => {
|
||||||
|
if let Err(err) = manager.set_filetransfer_params(params, password.as_deref()) {
|
||||||
|
eprintln!("{err}");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Remote::None => {}
|
||||||
|
}
|
||||||
|
manager.run(activity);
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user