summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2019-05-27 10:29:44 +0200
committerLinus Färnstrand <linus@mullvad.net>2019-05-27 13:30:49 +0200
commitaab51c57de7d93ab11e564f07313a19be9090aed (patch)
tree1193829a3a10ceacfb1b397db8b39b5107924ddc
parent18b3a48f84179301e47fbe14108d1770e0c03b52 (diff)
downloadmullvadvpn-aab51c57de7d93ab11e564f07313a19be9090aed.tar.xz
mullvadvpn-aab51c57de7d93ab11e564f07313a19be9090aed.zip
Automatically print help when no subcommand given
-rw-r--r--mullvad-cli/src/cmds/account.rs2
-rw-r--r--mullvad-cli/src/cmds/auto_connect.rs2
-rw-r--r--mullvad-cli/src/cmds/block_when_disconnected.rs2
-rw-r--r--mullvad-cli/src/cmds/lan.rs2
-rw-r--r--mullvad-cli/src/cmds/relay.rs4
-rw-r--r--mullvad-cli/src/cmds/tunnel.rs18
-rw-r--r--mullvad-cli/src/main.rs6
-rw-r--r--mullvad-problem-report/src/main.rs6
8 files changed, 25 insertions, 17 deletions
diff --git a/mullvad-cli/src/cmds/account.rs b/mullvad-cli/src/cmds/account.rs
index a480f95bde..5123f0a8f8 100644
--- a/mullvad-cli/src/cmds/account.rs
+++ b/mullvad-cli/src/cmds/account.rs
@@ -12,7 +12,7 @@ impl Command for Account {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Control and display information about your Mullvad account")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("set")
.about("Change account")
diff --git a/mullvad-cli/src/cmds/auto_connect.rs b/mullvad-cli/src/cmds/auto_connect.rs
index 6deccc9260..bad4c5c1e6 100644
--- a/mullvad-cli/src/cmds/auto_connect.rs
+++ b/mullvad-cli/src/cmds/auto_connect.rs
@@ -11,7 +11,7 @@ impl Command for AutoConnect {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Control the daemon auto-connect setting")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("set")
.about("Change auto-connect setting")
diff --git a/mullvad-cli/src/cmds/block_when_disconnected.rs b/mullvad-cli/src/cmds/block_when_disconnected.rs
index ad7dc00d4c..9d9081a650 100644
--- a/mullvad-cli/src/cmds/block_when_disconnected.rs
+++ b/mullvad-cli/src/cmds/block_when_disconnected.rs
@@ -11,7 +11,7 @@ impl Command for BlockWhenDisconnected {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Control if the system service should block network access when disconnected from VPN")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("set")
.about("Change the block when disconnected setting")
diff --git a/mullvad-cli/src/cmds/lan.rs b/mullvad-cli/src/cmds/lan.rs
index 437a5acaad..3a29bdd226 100644
--- a/mullvad-cli/src/cmds/lan.rs
+++ b/mullvad-cli/src/cmds/lan.rs
@@ -11,7 +11,7 @@ impl Command for Lan {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Control the allow local network sharing setting")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("set")
.about("Change allow LAN setting")
diff --git a/mullvad-cli/src/cmds/relay.rs b/mullvad-cli/src/cmds/relay.rs
index 7a202e4a5d..5cc8f2815b 100644
--- a/mullvad-cli/src/cmds/relay.rs
+++ b/mullvad-cli/src/cmds/relay.rs
@@ -25,13 +25,13 @@ impl Command for Relay {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Manage relay and tunnel constraints")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("set")
.about(
"Set relay server selection parameters. Such as location and port/protocol",
)
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("custom")
.about("Set a custom VPN relay")
diff --git a/mullvad-cli/src/cmds/tunnel.rs b/mullvad-cli/src/cmds/tunnel.rs
index 592aef74df..c02a88d03a 100644
--- a/mullvad-cli/src/cmds/tunnel.rs
+++ b/mullvad-cli/src/cmds/tunnel.rs
@@ -16,7 +16,7 @@ impl Command for Tunnel {
fn clap_subcommand(&self) -> clap::App<'static, 'static> {
clap::SubCommand::with_name(self.name())
.about("Manage tunnel specific options")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(create_openvpn_subcommand())
.subcommand(create_wireguard_subcommand())
.subcommand(create_ipv6_subcommand())
@@ -37,7 +37,7 @@ impl Command for Tunnel {
fn create_wireguard_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("wireguard")
.about("Manage options for Wireguard tunnels")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(create_wireguard_mtu_subcommand())
.subcommand(create_wireguard_keys_subcommand())
}
@@ -45,7 +45,7 @@ fn create_wireguard_subcommand() -> clap::App<'static, 'static> {
fn create_wireguard_mtu_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("mtu")
.about("Configure the MTU of the wireguard tunnel")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(clap::SubCommand::with_name("get"))
.subcommand(clap::SubCommand::with_name("unset"))
.subcommand(
@@ -56,7 +56,7 @@ fn create_wireguard_mtu_subcommand() -> clap::App<'static, 'static> {
fn create_wireguard_keys_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("key")
.about("Manage your wireguard keys")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(clap::SubCommand::with_name("check"))
.subcommand(clap::SubCommand::with_name("generate"))
}
@@ -65,7 +65,7 @@ fn create_wireguard_keys_subcommand() -> clap::App<'static, 'static> {
fn create_openvpn_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("openvpn")
.about("Manage options for OpenVPN tunnels")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(create_openvpn_mssfix_subcommand())
.subcommand(create_openvpn_proxy_subcommand())
}
@@ -73,7 +73,7 @@ fn create_openvpn_subcommand() -> clap::App<'static, 'static> {
fn create_openvpn_mssfix_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("mssfix")
.about("Configure the optional mssfix parameter")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(clap::SubCommand::with_name("get"))
.subcommand(clap::SubCommand::with_name("unset"))
.subcommand(
@@ -84,12 +84,12 @@ fn create_openvpn_mssfix_subcommand() -> clap::App<'static, 'static> {
fn create_openvpn_proxy_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("proxy")
.about("Configure a SOCKS5 proxy")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(clap::SubCommand::with_name("get"))
.subcommand(clap::SubCommand::with_name("unset"))
.subcommand(
clap::SubCommand::with_name("set")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(
clap::SubCommand::with_name("local")
.about("Registers a local SOCKS5 proxy")
@@ -174,7 +174,7 @@ fn create_openvpn_proxy_subcommand() -> clap::App<'static, 'static> {
fn create_ipv6_subcommand() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("ipv6")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
.subcommand(clap::SubCommand::with_name("get"))
.subcommand(
clap::SubCommand::with_name("set").arg(
diff --git a/mullvad-cli/src/main.rs b/mullvad-cli/src/main.rs
index fcb8246cfd..3dc1879fb8 100644
--- a/mullvad-cli/src/main.rs
+++ b/mullvad-cli/src/main.rs
@@ -68,7 +68,11 @@ fn run() -> Result<()> {
.version(PRODUCT_VERSION)
.author(crate_authors!())
.about(crate_description!())
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
+ .global_settings(&[
+ clap::AppSettings::DisableHelpSubcommand,
+ clap::AppSettings::VersionlessSubcommands,
+ ])
.subcommands(commands.values().map(|cmd| cmd.clap_subcommand()));
let app_matches = app.get_matches();
diff --git a/mullvad-problem-report/src/main.rs b/mullvad-problem-report/src/main.rs
index 8cd29edf8f..8d47ebbb98 100644
--- a/mullvad-problem-report/src/main.rs
+++ b/mullvad-problem-report/src/main.rs
@@ -117,7 +117,11 @@ fn run() -> Result<(), Error> {
.version(metadata::PRODUCT_VERSION)
.author(crate_authors!())
.about("Mullvad VPN problem report tool. Collects logs and sends them to Mullvad support.")
- .setting(clap::AppSettings::SubcommandRequired)
+ .setting(clap::AppSettings::SubcommandRequiredElseHelp)
+ .global_settings(&[
+ clap::AppSettings::DisableHelpSubcommand,
+ clap::AppSettings::VersionlessSubcommands,
+ ])
.subcommand(
clap::SubCommand::with_name("collect")
.about("Collect problem report")