diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-04-02 12:29:47 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-04-17 10:28:11 +0200 |
| commit | 07f3c3664312a66c974e2c417722bfd42e5fc051 (patch) | |
| tree | 3d70dbf0d708545ec00dd6ff19673a02808fc330 | |
| parent | 3d61f687ced3aef078223c8138871adfaeb9a862 (diff) | |
| download | mullvadvpn-07f3c3664312a66c974e2c417722bfd42e5fc051.tar.xz mullvadvpn-07f3c3664312a66c974e2c417722bfd42e5fc051.zip | |
Use conditional compilation for shell completions
| -rwxr-xr-x | build.sh | 21 | ||||
| -rw-r--r-- | mullvad-cli/Cargo.toml | 4 | ||||
| -rw-r--r-- | mullvad-cli/src/main.rs | 6 |
3 files changed, 20 insertions, 11 deletions
@@ -134,6 +134,18 @@ fi ./wireguard/build-wireguard-go.sh echo "Building Rust code in release mode using $RUSTC_VERSION..." + +if [[ ("$(uname -s)" == "Darwin") || ("$(uname -s)" == "Linux") ]]; then + pushd mullvad-cli + mkdir -p "$SCRIPT_DIR/dist-assets/shell-completions" + for sh in bash zsh; do + echo "Generating shell completion script for $sh..." + cargo +stable run $CARGO_ARGS --release --features shell-completions -- \ + shell-completions "$sh" "$SCRIPT_DIR/dist-assets/shell-completions/" + done + popd +fi + MULLVAD_ADD_MANIFEST="1" cargo +stable build $CARGO_ARGS --release ################################################################################ @@ -198,15 +210,6 @@ fi ./update-relays.sh -if [[ ("$(uname -s)" == "Darwin") || ("$(uname -s)" == "Linux") ]]; then - echo "Generating shell completion scripts..." - mkdir -p "$SCRIPT_DIR/dist-assets/shell-completions" - for sh in bash zsh; do - "$CARGO_TARGET_DIR/release/mullvad" shell-completions "$sh" \ - "$SCRIPT_DIR/dist-assets/shell-completions/" - done -fi - pushd "$SCRIPT_DIR/gui" echo "Installing JavaScript dependencies..." diff --git a/mullvad-cli/Cargo.toml b/mullvad-cli/Cargo.toml index ec51a613e3..4deb3f5cbf 100644 --- a/mullvad-cli/Cargo.toml +++ b/mullvad-cli/Cargo.toml @@ -7,6 +7,10 @@ license = "GPL-3.0" edition = "2018" publish = false +[features] +default = [] +shell-completions = [] + [[bin]] name = "mullvad" path = "src/main.rs" diff --git a/mullvad-cli/src/main.rs b/mullvad-cli/src/main.rs index ef91e606c8..3d8d2a4aef 100644 --- a/mullvad-cli/src/main.rs +++ b/mullvad-cli/src/main.rs @@ -52,6 +52,8 @@ fn run() -> Result<()> { let commands = cmds::get_commands(); let app = build_cli(&commands); + + #[cfg(feature = "shell-completions")] let app = app.subcommand( clap::SubCommand::with_name("shell-completions") .about("Generates completion scripts for your shell") @@ -65,12 +67,12 @@ fn run() -> Result<()> { clap::Arg::with_name("DIR") .default_value("./") .help("Output directory where the shell completions are written"), - ) - .setting(clap::AppSettings::Hidden), + ), ); let app_matches = app.get_matches(); match app_matches.subcommand() { + #[cfg(feature = "shell-completions")] ("shell-completions", Some(sub_matches)) => { let shell = sub_matches .value_of("SHELL") |
