diff options
| author | Fuwn <[email protected]> | 2021-05-10 16:11:52 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-10 16:11:52 -0700 |
| commit | 6922c6823ca9e29bf2a69e334bfd2c8a15740dc8 (patch) | |
| tree | 3cc6959f9d0d45b4bee76dc067046cbb89c9ae69 | |
| parent | perf(api): use actix_web instead of rocket for api (diff) | |
| download | whirl-6922c6823ca9e29bf2a69e334bfd2c8a15740dc8.tar.xz whirl-6922c6823ca9e29bf2a69e334bfd2c8a15740dc8.zip | |
feat(prompt): toggle prompt via configuration file
Adds the ability to enable or disable the Whirl Shell from a `Whirl.toml` file.
BREAKING CHANGE: `whirsplash.prompt.enable` configuration key created.
closes #19
| -rw-r--r-- | Whirl.toml.example | 3 | ||||
| -rw-r--r-- | src/config/Whirl.default.toml | 3 | ||||
| -rw-r--r-- | src/config/mod.rs | 8 | ||||
| -rw-r--r-- | src/subs.rs | 4 |
4 files changed, 17 insertions, 1 deletions
diff --git a/Whirl.toml.example b/Whirl.toml.example index ed6a874..330a88b 100644 --- a/Whirl.toml.example +++ b/Whirl.toml.example @@ -5,6 +5,9 @@ ip = "0.0.0.0" # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING prompt_ps1 = "[WORLDSMASTER@Whirlsplash ~]$" api.port = 8080 +[whirlsplash.prompt] +enable = false + [distributor] worldsmaster_greeting = "Welcome to Whirlsplash!" port = 6650 # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING diff --git a/src/config/Whirl.default.toml b/src/config/Whirl.default.toml index ed6a874..330a88b 100644 --- a/src/config/Whirl.default.toml +++ b/src/config/Whirl.default.toml @@ -5,6 +5,9 @@ ip = "0.0.0.0" # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING prompt_ps1 = "[WORLDSMASTER@Whirlsplash ~]$" api.port = 8080 +[whirlsplash.prompt] +enable = false + [distributor] worldsmaster_greeting = "Welcome to Whirlsplash!" port = 6650 # DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING diff --git a/src/config/mod.rs b/src/config/mod.rs index 6b50086..a71020d 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -10,12 +10,17 @@ pub struct WhirlsplashConfig { pub ip: String, pub prompt_ps1: String, pub api: WhirlsplashApiConfig, + pub prompt: WhirlsplashPromptConfig, } #[derive(Serialize, Deserialize, Debug)] pub struct WhirlsplashApiConfig { pub port: i64, } #[derive(Serialize, Deserialize, Debug)] +pub struct WhirlsplashPromptConfig { + pub enable: bool, +} +#[derive(Serialize, Deserialize, Debug)] pub struct DistributorConfig { pub worldsmaster_greeting: String, pub port: i64, @@ -62,6 +67,9 @@ impl Default for Config { api: WhirlsplashApiConfig { port: 80 }, + prompt: WhirlsplashPromptConfig { + enable: false + }, }, distributor: DistributorConfig { worldsmaster_greeting: "Welcome to Whirlsplash!".to_string(), diff --git a/src/subs.rs b/src/subs.rs index 0a7af5e..5ecf9bd 100644 --- a/src/subs.rs +++ b/src/subs.rs @@ -36,7 +36,9 @@ pub async fn run() -> ! { }), ]; - if std::env::var("DISABLE_PROMPT").unwrap_or_else(|_| "false".to_string()) == "true" { + if std::env::var("DISABLE_PROMPT").unwrap_or_else(|_| "false".to_string()) == "true" + || !Config::get().whirlsplash.prompt.enable + { info!("starting with prompt disabled"); loop { std::thread::sleep(std::time::Duration::default()); |