Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat: FVM self subcommand #3570

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
feat: add to path capabilities
  • Loading branch information
EstebanBorai committed Sep 30, 2023
commit 2d749a58dde0b226edd1a4afceced8281acd6ac1
21 changes: 20 additions & 1 deletion crates/fluvio-version-manager/src/command/itself/install.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::env::current_exe;
use std::fs::{create_dir, copy};
use std::fs::{create_dir, copy, write};
use std::path::PathBuf;

use clap::Parser;
Expand All @@ -12,6 +12,17 @@ use crate::common::notify::Notify;
use crate::common::settings::Settings;
use crate::common::workdir::{fvm_bin_path, fvm_workdir_path, fvm_pkgset_path};

const FVM_ENV_FILE_CONTENTS: &str = r#"
#!/bin/sh
case ":${PATH}:" in
*:"$HOME/.fvm/bin":*)
;;
*)
export PATH="$PATH:$HOME/.fvm/bin"
;;
esac
"#;

#[derive(Clone, Debug, Parser)]
pub struct InstallOpt {
EstebanBorai marked this conversation as resolved.
Show resolved Hide resolved
#[command(flatten)]
Expand All @@ -38,6 +49,10 @@ impl InstallOpt {
"FVM installed successfully at {}",
fvm_installation_path.display().italic()
));
self.notify_help(format!(
"Add FVM to PATH using {}",
"source $HOME/.fvm/env".bold()
));

Ok(())
}
Expand Down Expand Up @@ -72,6 +87,10 @@ impl InstallOpt {
let fvm_pkgset_dir = fvm_pkgset_path()?;
create_dir(fvm_pkgset_dir)?;

// Creates the `env` file
let fvm_env_file_path = fvm_dir.join("env");
sehz marked this conversation as resolved.
Show resolved Hide resolved
write(fvm_env_file_path, FVM_ENV_FILE_CONTENTS)?;

Ok(fvm_dir)
}
}
Expand Down