cli: avoid useless .into()

This needs latest proxmox-api updates.
This commit is contained in:
Dietmar Maurer 2019-12-09 17:40:34 +01:00
parent eb7e2ee00b
commit 48ef3c3327
5 changed files with 40 additions and 50 deletions

View File

@ -28,59 +28,52 @@ pub struct Shell {
pub fn catalog_shell_cli() -> CommandLineInterface {
let map = CliCommandMap::new()
.insert("pwd", CliCommand::new(&API_METHOD_PWD_COMMAND).into())
.insert("pwd", CliCommand::new(&API_METHOD_PWD_COMMAND))
.insert(
"cd",
CliCommand::new(&API_METHOD_CD_COMMAND)
.arg_param(&["path"])
.completion_cb("path", Shell::complete_path)
.into(),
)
.insert(
"ls",
CliCommand::new(&API_METHOD_LS_COMMAND)
.arg_param(&["path"])
.completion_cb("path", Shell::complete_path)
.into(),
)
)
.insert(
"stat",
CliCommand::new(&API_METHOD_STAT_COMMAND)
.arg_param(&["path"])
.completion_cb("path", Shell::complete_path)
.into(),
)
)
.insert(
"select",
CliCommand::new(&API_METHOD_SELECT_COMMAND)
.arg_param(&["path"])
.completion_cb("path", Shell::complete_path)
.into(),
)
.insert(
"deselect",
CliCommand::new(&API_METHOD_DESELECT_COMMAND)
.arg_param(&["path"])
.completion_cb("path", Shell::complete_path)
.into(),
)
.insert(
"restore-selected",
CliCommand::new(&API_METHOD_RESTORE_SELECTED_COMMAND)
.arg_param(&["target"])
.completion_cb("target", tools::complete_file_name)
.into(),
)
.insert(
"list-selected",
CliCommand::new(&API_METHOD_LIST_SELECTED_COMMAND).into(),
CliCommand::new(&API_METHOD_LIST_SELECTED_COMMAND),
)
.insert(
"restore",
CliCommand::new(&API_METHOD_RESTORE_COMMAND)
.arg_param(&["target"])
.completion_cb("target", tools::complete_file_name)
.into(),
)
.insert_help();

View File

@ -61,10 +61,11 @@ fn quit_command() -> Result<(), Error> {
fn cli_definition() -> CommandLineInterface {
let cmd_def = CliCommandMap::new()
.insert("quit", CliCommand::new(&API_METHOD_QUIT_COMMAND).into())
.insert("hello", CliCommand::new(&API_METHOD_HELLO_COMMAND).into())
.insert("quit", CliCommand::new(&API_METHOD_QUIT_COMMAND))
.insert("hello", CliCommand::new(&API_METHOD_HELLO_COMMAND))
.insert("echo", CliCommand::new(&API_METHOD_ECHO_COMMAND)
.arg_param(&["text"]).into())
.arg_param(&["text"])
)
.insert_help();
CommandLineInterface::Nested(cmd_def)

View File

@ -1651,10 +1651,10 @@ fn key_mgmt_cli() -> CliCommandMap {
.completion_cb("path", tools::complete_file_name);
CliCommandMap::new()
.insert("create", key_create_cmd_def.into())
.insert("create-master-key", key_create_master_key_cmd_def.into())
.insert("import-master-pubkey", key_import_master_pubkey_cmd_def.into())
.insert("change-passphrase", key_change_passphrase_cmd_def.into())
.insert("create", key_create_cmd_def)
.insert("create-master-key", key_create_master_key_cmd_def)
.insert("import-master-pubkey", key_import_master_pubkey_cmd_def)
.insert("change-passphrase", key_change_passphrase_cmd_def)
}
fn mount(
@ -1945,8 +1945,8 @@ fn catalog_mgmt_cli() -> CliCommandMap {
.completion_cb("snapshot", complete_backup_snapshot);
CliCommandMap::new()
.insert("dump", catalog_dump_cmd_def.into())
.insert("shell", catalog_shell_cmd_def.into())
.insert("dump", catalog_dump_cmd_def)
.insert("shell", catalog_shell_cmd_def)
}
@ -2285,23 +2285,23 @@ We do not extraxt '.pxar' archives when writing to stdandard output.
let cmd_def = CliCommandMap::new()
.insert("backup", backup_cmd_def.into())
.insert("upload-log", upload_log_cmd_def.into())
.insert("forget", forget_cmd_def.into())
.insert("garbage-collect", garbage_collect_cmd_def.into())
.insert("list", list_cmd_def.into())
.insert("login", login_cmd_def.into())
.insert("logout", logout_cmd_def.into())
.insert("prune", prune_cmd_def.into())
.insert("restore", restore_cmd_def.into())
.insert("snapshots", snapshots_cmd_def.into())
.insert("files", files_cmd_def.into())
.insert("status", status_cmd_def.into())
.insert("key", key_mgmt_cli().into())
.insert("mount", mount_cmd_def.into())
.insert("catalog", catalog_mgmt_cli().into());
.insert("backup", backup_cmd_def)
.insert("upload-log", upload_log_cmd_def)
.insert("forget", forget_cmd_def)
.insert("garbage-collect", garbage_collect_cmd_def)
.insert("list", list_cmd_def)
.insert("login", login_cmd_def)
.insert("logout", logout_cmd_def)
.insert("prune", prune_cmd_def)
.insert("restore", restore_cmd_def)
.insert("snapshots", snapshots_cmd_def)
.insert("files", files_cmd_def)
.insert("status", status_cmd_def)
.insert("key", key_mgmt_cli())
.insert("mount", mount_cmd_def)
.insert("catalog", catalog_mgmt_cli());
run_cli_command(cmd_def.into());
run_cli_command(cmd_def);
}
fn async_main<F: Future>(fut: F) -> <F as Future>::Output {

View File

@ -8,16 +8,16 @@ fn datastore_commands() -> CommandLineInterface {
use proxmox_backup::api2;
let cmd_def = CliCommandMap::new()
.insert("list", CliCommand::new(&api2::config::datastore::GET).into())
.insert("list", CliCommand::new(&api2::config::datastore::GET))
.insert("create",
CliCommand::new(&api2::config::datastore::POST)
.arg_param(&["name", "path"])
.into())
)
.insert("remove",
CliCommand::new(&api2::config::datastore::DELETE)
.arg_param(&["name"])
.completion_cb("name", config::datastore::complete_datastore_name)
.into());
);
cmd_def.into()
}
@ -34,12 +34,12 @@ fn garbage_collection_commands() -> CommandLineInterface {
CliCommand::new(&api2::admin::datastore::API_METHOD_GARBAGE_COLLECTION_STATUS)
.arg_param(&["store"])
.completion_cb("store", config::datastore::complete_datastore_name)
.into())
)
.insert("start",
CliCommand::new(&api2::admin::datastore::API_METHOD_START_GARBAGE_COLLECTION)
.arg_param(&["store"])
.completion_cb("store", config::datastore::complete_datastore_name)
.into());
);
cmd_def.into()
}
@ -47,8 +47,8 @@ fn garbage_collection_commands() -> CommandLineInterface {
fn main() {
let cmd_def = CliCommandMap::new()
.insert("datastore".to_owned(), datastore_commands())
.insert("garbage-collection".to_owned(), garbage_collection_commands());
.insert("datastore", datastore_commands())
.insert("garbage-collection", garbage_collection_commands());
run_cli_command(cmd_def.into());
run_cli_command(cmd_def);
}

View File

@ -491,26 +491,22 @@ fn main() {
.arg_param(&["archive", "source", "exclude"])
.completion_cb("archive", tools::complete_file_name)
.completion_cb("source", tools::complete_file_name)
.into()
)
.insert("extract", CliCommand::new(&API_METHOD_EXTRACT_ARCHIVE)
.arg_param(&["archive", "pattern"])
.completion_cb("archive", tools::complete_file_name)
.completion_cb("target", tools::complete_file_name)
.completion_cb("files-from", tools::complete_file_name)
.into()
)
)
.insert("mount", CliCommand::new(&API_METHOD_MOUNT_ARCHIVE)
.arg_param(&["archive", "mountpoint"])
.completion_cb("archive", tools::complete_file_name)
.completion_cb("mountpoint", tools::complete_file_name)
.into()
)
.insert("list", CliCommand::new(&API_METHOD_DUMP_ARCHIVE)
.arg_param(&["archive"])
.completion_cb("archive", tools::complete_file_name)
.into()
);
run_cli_command(cmd_def.into());
run_cli_command(cmd_def);
}