diff --git a/src/cli.rs b/src/cli.rs index 49d8f76e5..0d8f8838e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -22,6 +22,13 @@ pub enum SubCommand { Use(commands::r#use::Use), /// Print and set up required environment variables for fnm + /// + /// This command generates a series of shell commands that + /// should be evaluated by your shell to create a fnm-ready environment. + /// + /// Each shell has its own syntax of evaluating a dynamic expression. + /// For example, evaluating fnm on Bash and Zsh would look like `eval "$(fnm env)"`. + /// In Fish, evaluating would look like `fnm env | source` #[structopt(name = "env")] Env(commands::env::Env), @@ -78,6 +85,7 @@ impl SubCommand { } } +/// A fast and simple Node.js manager. #[derive(StructOpt, Debug)] #[structopt(name = "fnm")] pub struct Cli { diff --git a/src/commands/env.rs b/src/commands/env.rs index a84b89eda..c3948a727 100644 --- a/src/commands/env.rs +++ b/src/commands/env.rs @@ -15,7 +15,7 @@ pub struct Env { #[structopt(possible_values = AVAILABLE_SHELLS)] shell: Option>, /// Deprecated. This is the default now. - #[structopt(long)] + #[structopt(long, hidden = true)] multi: bool, /// Print the script to change Node versions every directory change #[structopt(long)] diff --git a/src/commands/install.rs b/src/commands/install.rs index 93a3c2ddf..754876db1 100644 --- a/src/commands/install.rs +++ b/src/commands/install.rs @@ -18,7 +18,7 @@ pub struct Install { pub version: Option, /// Install latest LTS - #[structopt(long)] + #[structopt(long, conflicts_with = "version")] pub lts: bool, } diff --git a/src/commands/use.rs b/src/commands/use.rs index 37576050d..08c66f23f 100644 --- a/src/commands/use.rs +++ b/src/commands/use.rs @@ -86,8 +86,12 @@ impl Command for Use { } }; - fs::remove_symlink_dir(&multishell_path).context(SymlinkingDeletionIssue)?; - fs::symlink_dir(version_path, &multishell_path).context(SymlinkingCreationIssue)?; + let symlink_deletion_result = fs::remove_symlink_dir(&multishell_path); + let symlink_result = fs::symlink_dir(version_path, &multishell_path); + + symlink_result + .or(symlink_deletion_result) + .context(SymlinkingCreationIssue)?; Ok(()) } @@ -145,8 +149,6 @@ fn warn_if_multishell_path_not_in_path_env_var( pub enum Error { #[snafu(display("Can't create the symlink: {}", source))] SymlinkingCreationIssue { source: std::io::Error }, - #[snafu(display("Can't delete the symlink: {}", source))] - SymlinkingDeletionIssue { source: std::io::Error }, #[snafu(display("{}", source))] InstallError { source: ::Error }, #[snafu(display("Can't get locally installed versions: {}", source))] diff --git a/src/config.rs b/src/config.rs index 1a78d0224..117381ad3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,8 +16,15 @@ pub struct FnmConfig { #[structopt(long = "fnm-dir", env = "FNM_DIR")] pub base_dir: Option, - /// Where the current node version link is stored - #[structopt(long, env = "FNM_MULTISHELL_PATH")] + /// Where the current node version link is stored. + /// This value will be populated automatically by evaluating + /// `fnm env` in your shell profile. Read more about it using `fnm help env` + #[structopt( + long, + env = "FNM_MULTISHELL_PATH", + hide_env_values = true, + hidden = true + )] multishell_path: Option, /// The log level of fnm commands