diff --git a/src/main.rs b/src/main.rs index df28395..8c7fe63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use std::io::Write; extern crate clap; use clap::{Command, arg, command}; -use pkh::context::ContextConfig; extern crate flate2; @@ -274,33 +273,6 @@ fn main() { .help("Print the pkh-native tag catalog and exit"), ), ) - .subcommand( - Command::new("context") - .about("Manage contexts") - .subcommand_required(true) - .subcommand( - Command::new("create") - .about("Create a new context") - .arg(arg!( "Context name")) - .arg(arg!(--type "Context type: ssh (only type supported for now)")) - .arg(arg!(--endpoint "Context endpoint (for example: ssh://user@host:port)")) - ) - .subcommand( - Command::new("rm") - .about("Remove a context") - .arg(arg!( "Context name")) - ) - .subcommand( - Command::new("ls") - .about("List contexts") - ) - .subcommand(Command::new("show").about("Show current context")) - .subcommand( - Command::new("use") - .about("Set current context") - .arg(arg!( "Context name")) - ) - ) .subcommand( Command::new("prune") .about("Prune residual pkh build artifacts and caches") @@ -716,80 +688,6 @@ fn main() { } } } - Some(("context", sub_matches)) => { - let mgr = pkh::context::manager(); - - match sub_matches.subcommand() { - Some(("create", args)) => { - let name = args.get_one::("name").unwrap(); - let type_str = args - .get_one::("type") - .map(|s| s.as_str()) - .unwrap_or("local"); - - let context = match type_str { - "local" => ContextConfig::Local, - "ssh" => { - let endpoint = - args.get_one::("endpoint").unwrap_or_else(|| { - error!( - "An --endpoint is required to create an ssh context. \ - Expected format: [ssh://][user@]host[:port]" - ); - std::process::exit(1); - }); - - match pkh::context::ContextConfig::from_endpoint(endpoint) { - Ok(config) => config, - Err(e) => { - error!("{e}"); - std::process::exit(1); - } - } - } - _ => { - error!("Unknown context type: {}", type_str); - std::process::exit(1); - } - }; - - if let Err(e) = mgr.add_context(name, context) { - error!("Failed to create context: {}", e); - std::process::exit(1); - } - info!("Context '{}' created.", name); - } - Some(("rm", args)) => { - let name = args.get_one::("name").unwrap(); - if let Err(e) = mgr.remove_context(name) { - error!("Failed to remove context: {}", e); - std::process::exit(1); - } - info!("Context '{}' removed.", name); - } - Some(("ls", _)) => { - let contexts = mgr.list_contexts(); - let current = mgr.current_name(); - for ctx in contexts { - if ctx == current { - println!("* {}", ctx); - } else { - println!(" {}", ctx); - } - } - } - Some(("show", _)) => {} - Some(("use", args)) => { - let name = args.get_one::("name").unwrap(); - if let Err(e) = mgr.set_current(name) { - error!("Failed to set context: {}", e); - std::process::exit(1); - } - info!("Switched to context '{}'.", name); - } - _ => unreachable!(), - } - } Some(("prune", sub_matches)) => { let dry_run = sub_matches .get_one::("dry_run")