summaryrefslogtreecommitdiffhomepage
path: root/mullvad-cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'mullvad-cli/src')
-rw-r--r--mullvad-cli/src/cmds/custom_lists.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/mullvad-cli/src/cmds/custom_lists.rs b/mullvad-cli/src/cmds/custom_lists.rs
index 9c0770a442..3c93b7eb75 100644
--- a/mullvad-cli/src/cmds/custom_lists.rs
+++ b/mullvad-cli/src/cmds/custom_lists.rs
@@ -9,11 +9,13 @@ use mullvad_types::{
#[derive(Subcommand, Debug)]
pub enum CustomList {
- /// Get names of custom lists
- List,
-
- /// Retrieve a custom list by its name
- Get { name: String },
+ /// List all custom lists or retrieve a custom list by its name
+ List {
+ // TODO: Would be cool to provide dynamic auto-completion:
+ // https://github.com/clap-rs/clap/issues/1232
+ /// A custom list. If omitted, all custom lists are shown
+ name: Option<String>,
+ },
/// Create a new custom list
Create { name: String },
@@ -42,8 +44,8 @@ pub enum CustomList {
impl CustomList {
pub async fn handle(self) -> Result<()> {
match self {
- CustomList::List => Self::list().await,
- CustomList::Get { name } => Self::get(name).await,
+ 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,
@@ -52,6 +54,7 @@ impl CustomList {
}
}
+ /// Print all custom lists.
async fn list() -> Result<()> {
let mut rpc = MullvadProxyClient::new().await?;
for custom_list in rpc.list_custom_lists().await? {
@@ -60,6 +63,8 @@ impl CustomList {
Ok(())
}
+ /// Print a specific custom list (if it exists).
+ /// If the list does not exist, print an error.
async fn get(name: String) -> Result<()> {
let mut rpc = MullvadProxyClient::new().await?;
let custom_list = rpc.get_custom_list(name).await?;