From 79bcdb5cbc4f661c5e0e1b167fc8eae1104ca33c Mon Sep 17 00:00:00 2001 From: Elouan Da Costa Peixoto Date: Mon, 30 Jun 2025 12:44:03 +0200 Subject: [PATCH 1/4] feat: add install script and update config.toml to add install alias --- .cargo/config.toml | 3 ++- install.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 install.sh diff --git a/.cargo/config.toml b/.cargo/config.toml index dc7a348..11db68a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,11 +4,12 @@ br = "build --release" c = "check" t = "test" r = "run" +i = "install --path ." rr = "run --release" w = "clippy -- -D warnings" recursive_example = "rr --example recursions" space_example = ["run", "--release", "--", "\"command list\""] [future-incompat-report] -frequency = 'always' # when to display a notification about a future incompat report +frequency = 'always' # When to display a notification about a future incompatible report diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..bcf2031 --- /dev/null +++ b/install.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +if ! command -v rustc +then + echo "Rust is not installed. Please install Rust first." + exit 1 +fi + +if ! command -V cargo +then + echo "cargo is not installed. Please install cargo first." + exit 1 +fi + +SHELL_NAME=$(basename "$SHELL") + +if [ "$SHELL_NAME" = "zsh" ]; then + CONFIG_FILE="$HOME/.zshrc" +elif [ "$SHELL_NAME" = "bash" ]; then + CONFIG_FILE="$HOME/.bashrc" +else + echo "Unknown Shell : $SHELL_NAME" + exit 1 +fi + +echo export NYX=$(pwd) >> "$CONFIG_FILE" +echo "NYX env var successfully added" + +cargo br +cargo i + +source "$CONFIG_FILE" + +if ! command -v nyx +then + echo "Error when installing NYX. Please try again." + exit 2 +fi + +echo "NYX has been successfully installed." From 2c4bd4bf3b6234d2c60abe90faac629b94dc1c2a Mon Sep 17 00:00:00 2001 From: Elouan Da Costa Peixoto Date: Mon, 30 Jun 2025 12:55:02 +0200 Subject: [PATCH 2/4] feat: add export path .cargo/bin in install.sh --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index bcf2031..46ed176 100644 --- a/install.sh +++ b/install.sh @@ -23,6 +23,7 @@ else exit 1 fi +echo export PATH=$PATH:~/.cargo/bin/ echo export NYX=$(pwd) >> "$CONFIG_FILE" echo "NYX env var successfully added" From 0c5424d8693c80215f351d402e82a20de54d7c7c Mon Sep 17 00:00:00 2001 From: Elouan Da Costa Peixoto Date: Mon, 30 Jun 2025 12:58:15 +0200 Subject: [PATCH 3/4] fix: export cargo/bin to echo in bashrc --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 46ed176..049e606 100644 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ else exit 1 fi -echo export PATH=$PATH:~/.cargo/bin/ +echo export PATH=$PATH:~/.cargo/bin/ >> "$CONFIG_FILE" echo export NYX=$(pwd) >> "$CONFIG_FILE" echo "NYX env var successfully added" From 7e148c51514314aee36b0ba0436d52ea06cd8ccf Mon Sep 17 00:00:00 2001 From: Elouan Da Costa Peixoto Date: Mon, 30 Jun 2025 13:10:39 +0200 Subject: [PATCH 4/4] fix: init config file and remove useless line in install.sh --- install.sh | 6 ------ src/nxfs/config.rs | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 049e606..8e17422 100644 --- a/install.sh +++ b/install.sh @@ -32,10 +32,4 @@ cargo i source "$CONFIG_FILE" -if ! command -v nyx -then - echo "Error when installing NYX. Please try again." - exit 2 -fi - echo "NYX has been successfully installed." diff --git a/src/nxfs/config.rs b/src/nxfs/config.rs index 49c090f..4598f6d 100644 --- a/src/nxfs/config.rs +++ b/src/nxfs/config.rs @@ -111,7 +111,7 @@ pub struct ConfigSecure { fn config_template() -> &'static str { (r"[config] format = 'nxs_config' -version = '0.4.0' +version = '0.4.1' [user] name = '' @@ -136,12 +136,11 @@ logs = '' cache = '' [security] -secure_mode = false +secure_mode = true ") as _ } pub fn config_command() { - change_work_dir(&utils::env::get_nyx_env_var()); let args: Vec = env::args().collect(); if args.len() <= 2 { command_usage(config_help()); @@ -158,6 +157,7 @@ pub fn config_command() { } fn init_config() { + change_work_dir(&utils::env::get_nyx_env_var()); let config_path = ".nxfs/config.toml"; let mut config_file = match File::create_new(config_path) { Ok(f) => f,