Compare commits
1
Commits
v0.5.3
..
a49bd47e8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a49bd47e8c |
@@ -11,12 +11,11 @@ use std::{
|
|||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let global_matches = cli::parser().get_matches();
|
let res = match cli::parser().get_matches().subcommand() {
|
||||||
let res = match global_matches.subcommand() {
|
|
||||||
None | Some(("run", _)) => launch_gui(),
|
None | Some(("run", _)) => launch_gui(),
|
||||||
Some(("get", m)) => cli::get(m, &global_matches),
|
Some(("get", m)) => cli::get(m),
|
||||||
Some(("exec", m)) => cli::exec(m, &global_matches),
|
Some(("exec", m)) => cli::exec(m),
|
||||||
Some(("shortcut", m)) => cli::invoke_shortcut(m, &global_matches),
|
Some(("shortcut", m)) => cli::invoke_shortcut(m),
|
||||||
_ => unreachable!("Unknown subcommand"),
|
_ => unreachable!("Unknown subcommand"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ pub fn parser() -> Command<'static> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn get(args: &ArgMatches, global_args: &ArgMatches) -> Result<(), CliError> {
|
pub fn get(args: &ArgMatches) -> Result<(), CliError> {
|
||||||
let name = args.get_one("name").cloned();
|
let name = args.get_one("name").cloned();
|
||||||
let base = *args.get_one("base").unwrap_or(&false);
|
let base = *args.get_one("base").unwrap_or(&false);
|
||||||
let addr = global_args.get_one("server_addr").cloned();
|
let addr = args.get_one("server_addr").cloned();
|
||||||
|
|
||||||
let output = match make_request(addr, &Request::GetAwsCredentials { name, base })? {
|
let output = match make_request(addr, &Request::GetAwsCredentials { name, base })? {
|
||||||
Response::AwsBase(creds) => serde_json::to_string(&creds).unwrap(),
|
Response::AwsBase(creds) => serde_json::to_string(&creds).unwrap(),
|
||||||
@@ -117,10 +117,10 @@ pub fn get(args: &ArgMatches, global_args: &ArgMatches) -> Result<(), CliError>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn exec(args: &ArgMatches, global_args: &ArgMatches) -> Result<(), CliError> {
|
pub fn exec(args: &ArgMatches) -> Result<(), CliError> {
|
||||||
let name = args.get_one("name").cloned();
|
let name = args.get_one("name").cloned();
|
||||||
let base = *args.get_one("base").unwrap_or(&false);
|
let base = *args.get_one("base").unwrap_or(&false);
|
||||||
let addr = global_args.get_one("server_addr").cloned();
|
let addr = args.get_one("server_addr").cloned();
|
||||||
let mut cmd_line = args.get_many("command")
|
let mut cmd_line = args.get_many("command")
|
||||||
.ok_or(ExecError::NoCommand)?;
|
.ok_or(ExecError::NoCommand)?;
|
||||||
|
|
||||||
@@ -172,8 +172,8 @@ pub fn exec(args: &ArgMatches, global_args: &ArgMatches) -> Result<(), CliError>
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn invoke_shortcut(args: &ArgMatches, global_args: &ArgMatches) -> Result<(), CliError> {
|
pub fn invoke_shortcut(args: &ArgMatches) -> Result<(), CliError> {
|
||||||
let addr = global_args.get_one("server_addr").cloned();
|
let addr = args.get_one("server_addr").cloned();
|
||||||
let action = match args.get_one::<String>("action").map(|s| s.as_str()) {
|
let action = match args.get_one::<String>("action").map(|s| s.as_str()) {
|
||||||
Some("show_window") => ShortcutAction::ShowWindow,
|
Some("show_window") => ShortcutAction::ShowWindow,
|
||||||
Some("launch_terminal") => ShortcutAction::LaunchTerminal,
|
Some("launch_terminal") => ShortcutAction::LaunchTerminal,
|
||||||
|
|||||||
Reference in New Issue
Block a user