diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-08-07 11:33:40 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-08-21 17:02:26 +0200 |
| commit | a64c0156af2a7b24e0c6313b8edac877baada3cf (patch) | |
| tree | de727274b034ab4e66c25decfc3e581ace375568 | |
| parent | 9a873502c9401887bdca445874ea216ff341b982 (diff) | |
| download | mullvadvpn-a64c0156af2a7b24e0c6313b8edac877baada3cf.tar.xz mullvadvpn-a64c0156af2a7b24e0c6313b8edac877baada3cf.zip | |
Re-arrange `mullvad custom-list` subcommands
Re-arrange most of the subcommands of `mullvad custom-list` to decrease
clutter. This includes both re-ordering the different subcommands as
well as moving some subcommands to a new umbrella subcommand `mullvad
custom-list edit`.
The subcommands under `mullvad custom-list edit` operate on a single
custom list, i.e. appending to/renaming/deleting from a custom list.
The other subcommands under `mullvad custom-list` operate on the global
set of lists instead.
| -rw-r--r-- | mullvad-cli/src/cmds/custom_lists.rs | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/mullvad-cli/src/cmds/custom_lists.rs b/mullvad-cli/src/cmds/custom_lists.rs index 3c93b7eb75..441032a381 100644 --- a/mullvad-cli/src/cmds/custom_lists.rs +++ b/mullvad-cli/src/cmds/custom_lists.rs @@ -9,7 +9,13 @@ use mullvad_types::{ #[derive(Subcommand, Debug)] pub enum CustomList { - /// List all custom lists or retrieve a custom list by its name + /// Create a new custom list + New { + /// A name for the new custom list + name: String, + }, + + /// Show all custom lists or retrieve a specific custom list List { // TODO: Would be cool to provide dynamic auto-completion: // https://github.com/clap-rs/clap/issues/1232 @@ -17,28 +23,42 @@ pub enum CustomList { name: Option<String>, }, - /// Create a new custom list - Create { name: String }, + /// Edit a custom list + #[clap(subcommand)] + Edit(EditCommand), - /// Add a location to the list + /// Delete a custom list + Delete { + /// A custom list + name: String, + }, +} + +#[derive(Subcommand, Debug)] +pub enum EditCommand { + /// Add a location to some custom list Add { + /// A custom list name: String, #[command(flatten)] location: LocationArgs, }, - /// Remove a location from the list + /// Remove a location from some custom list Remove { + /// A custom list name: String, #[command(flatten)] location: LocationArgs, }, - /// Delete the custom list - Delete { name: String }, - - /// Rename a custom list to a new name - Rename { name: String, new_name: String }, + /// Rename a custom list + Rename { + /// Current name of the custom list + name: String, + /// A new name for the custom list + new_name: String, + }, } impl CustomList { @@ -46,11 +66,15 @@ impl CustomList { match self { CustomList::List { name: None } => Self::list().await, CustomList::List { name: Some(name) } => Self::get(name).await, - CustomList::Create { name } => Self::create_list(name).await, - CustomList::Add { name, location } => Self::add_location(name, location).await, - CustomList::Remove { name, location } => Self::remove_location(name, location).await, + CustomList::New { name } => Self::create_list(name).await, CustomList::Delete { name } => Self::delete_list(name).await, - CustomList::Rename { name, new_name } => Self::rename_list(name, new_name).await, + CustomList::Edit(cmd) => match cmd { + EditCommand::Add { name, location } => Self::add_location(name, location).await, + EditCommand::Rename { name, new_name } => Self::rename_list(name, new_name).await, + EditCommand::Remove { name, location } => { + Self::remove_location(name, location).await + } + }, } } |
