mirror of
https://github.com/veeso/termscp.git
synced 2026-04-03 16:51:21 -07:00
feat: Import bookmarks from ssh config with a CLI command (#364)
* feat: Import bookmarks from ssh config with a CLI command Use import-ssh-hosts to import all the possible hosts by the configured ssh config or the default one on your machine closes #331
This commit is contained in:
committed by
GitHub
parent
4bebec369f
commit
f4156a5059
26
src/cli.rs
26
src/cli.rs
@@ -15,6 +15,9 @@ use crate::system::logging::LogLevel;
|
||||
|
||||
pub enum Task {
|
||||
Activity(NextActivity),
|
||||
/// Import ssh hosts from the specified ssh config file, or from the default location
|
||||
/// and save them as bookmarks.
|
||||
ImportSshHosts(Option<PathBuf>),
|
||||
ImportTheme(PathBuf),
|
||||
InstallUpdate,
|
||||
Version,
|
||||
@@ -72,7 +75,8 @@ pub struct Args {
|
||||
#[argh(subcommand)]
|
||||
pub enum ArgsSubcommands {
|
||||
Config(ConfigArgs),
|
||||
LoadTheme(LoadThemeArgs),
|
||||
ImportSshHosts(ImportSshHostsArgs),
|
||||
ImportTheme(ImportThemeArgs),
|
||||
Update(UpdateArgs),
|
||||
}
|
||||
|
||||
@@ -86,10 +90,20 @@ pub struct ConfigArgs {}
|
||||
#[argh(subcommand, name = "update")]
|
||||
pub struct UpdateArgs {}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
/// import ssh hosts from the specified ssh config file, or from the default location
|
||||
/// and save them as bookmarks.
|
||||
#[argh(subcommand, name = "import-ssh-hosts")]
|
||||
pub struct ImportSshHostsArgs {
|
||||
#[argh(positional)]
|
||||
/// optional ssh config file; if not specified, the default location will be used
|
||||
pub ssh_config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
/// import the specified theme
|
||||
#[argh(subcommand, name = "theme")]
|
||||
pub struct LoadThemeArgs {
|
||||
pub struct ImportThemeArgs {
|
||||
#[argh(positional)]
|
||||
/// theme file
|
||||
pub theme: PathBuf,
|
||||
@@ -118,6 +132,14 @@ impl RunOpts {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn import_ssh_hosts(ssh_config: Option<PathBuf>, keyring: bool) -> Self {
|
||||
Self {
|
||||
task: Task::ImportSshHosts(ssh_config),
|
||||
keyring,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn import_theme(theme: PathBuf) -> Self {
|
||||
Self {
|
||||
task: Task::ImportTheme(theme),
|
||||
|
||||
Reference in New Issue
Block a user