aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-17 11:06:36 -0700
committerFuwn <[email protected]>2021-05-17 11:06:36 -0700
commit59e8fdecf8b37f7bbd646017e58d1b57f1fd15c7 (patch)
tree28138d85351b7900cfc52667e778a8765d2619f5
parentchore(todo): delete todo.md (diff)
downloadwhirl-59e8fdecf8b37f7bbd646017e58d1b57f1fd15c7.tar.xz
whirl-59e8fdecf8b37f7bbd646017e58d1b57f1fd15c7.zip
refactor(global): move constants and structures to their respective modules
-rw-r--r--whirl_config/src/lib.rs44
-rw-r--r--whirl_config/src/structures.rs37
-rw-r--r--whirl_prompt/src/builtins.rs17
-rw-r--r--whirl_prompt/src/constants.rs19
-rw-r--r--whirl_prompt/src/lib.rs1
5 files changed, 68 insertions, 50 deletions
diff --git a/whirl_config/src/lib.rs b/whirl_config/src/lib.rs
index a4d23e5..48ad925 100644
--- a/whirl_config/src/lib.rs
+++ b/whirl_config/src/lib.rs
@@ -6,42 +6,18 @@ extern crate serde_derive;
#[macro_use]
extern crate log;
+mod structures;
+
use config::{ConfigError, File};
-#[derive(Serialize, Deserialize, Debug)]
-pub struct WhirlsplashConfig {
- pub worldsmaster_username: String,
- pub ip: String,
- pub api: WhirlsplashApiConfig,
- pub prompt: WhirlsplashPromptConfig,
- pub log: WhirlsplashLogConfig,
-}
-#[derive(Serialize, Deserialize, Debug)]
-pub struct WhirlsplashApiConfig {
- pub port: i64,
-}
-#[derive(Serialize, Deserialize, Debug)]
-pub struct WhirlsplashPromptConfig {
- pub enable: bool,
- pub ps1: String,
-}
-#[derive(Serialize, Deserialize, Debug)]
-pub struct WhirlsplashLogConfig {
- pub enable: bool,
- pub level: i64,
- pub everything: bool,
- pub test: bool,
- pub file: bool,
-}
-#[derive(Serialize, Deserialize, Debug)]
-pub struct DistributorConfig {
- pub worldsmaster_greeting: String,
- pub port: i64,
-}
-#[derive(Serialize, Deserialize, Debug)]
-pub struct HubConfig {
- pub port: i64,
-}
+use crate::structures::{
+ DistributorConfig,
+ HubConfig,
+ WhirlsplashApiConfig,
+ WhirlsplashConfig,
+ WhirlsplashLogConfig,
+ WhirlsplashPromptConfig,
+};
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
diff --git a/whirl_config/src/structures.rs b/whirl_config/src/structures.rs
new file mode 100644
index 0000000..4f1d62e
--- /dev/null
+++ b/whirl_config/src/structures.rs
@@ -0,0 +1,37 @@
+// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
+// SPDX-License-Identifier: GPL-3.0-only
+
+#[derive(Serialize, Deserialize, Debug)]
+pub struct WhirlsplashConfig {
+ pub worldsmaster_username: String,
+ pub ip: String,
+ pub api: WhirlsplashApiConfig,
+ pub prompt: WhirlsplashPromptConfig,
+ pub log: WhirlsplashLogConfig,
+}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct WhirlsplashApiConfig {
+ pub port: i64,
+}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct WhirlsplashPromptConfig {
+ pub enable: bool,
+ pub ps1: String,
+}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct WhirlsplashLogConfig {
+ pub enable: bool,
+ pub level: i64,
+ pub everything: bool,
+ pub test: bool,
+ pub file: bool,
+}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct DistributorConfig {
+ pub worldsmaster_greeting: String,
+ pub port: i64,
+}
+#[derive(Serialize, Deserialize, Debug)]
+pub struct HubConfig {
+ pub port: i64,
+}
diff --git a/whirl_prompt/src/builtins.rs b/whirl_prompt/src/builtins.rs
index 442aeb5..b0d02e1 100644
--- a/whirl_prompt/src/builtins.rs
+++ b/whirl_prompt/src/builtins.rs
@@ -6,22 +6,7 @@ use std::{io::Write, str::FromStr};
use sysinfo::SystemExt;
use whirl_config::Config;
-const FILES: [&str; 2] = ["README.rst", "Whirl.toml"];
-const HELPABLES_BUILTINS: [&str; 8] = [
- "cat - display the contents of a present file",
- "config - manipulate the configuration",
- "echo - display a line of predefined text",
- "exit - end the process",
- "fetch - a neofetch like utility loosely based on rfetch",
- "help - you are here",
- "history - display the command history",
- "ls - display the present files",
-];
-const HELPABLES_BUILTIN_CONFIG: [&str; 3] = [
- "help - you are here",
- "refresh - reload the configuration file",
- "show - display the current configuration",
-];
+use crate::constants::{FILES, HELPABLES_BUILTINS, HELPABLES_BUILTIN_CONFIG};
pub enum BuiltIn {
Echo,
diff --git a/whirl_prompt/src/constants.rs b/whirl_prompt/src/constants.rs
new file mode 100644
index 0000000..c173a57
--- /dev/null
+++ b/whirl_prompt/src/constants.rs
@@ -0,0 +1,19 @@
+// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective
+// SPDX-License-Identifier: GPL-3.0-only
+
+pub const FILES: [&str; 2] = ["README.rst", "Whirl.toml"];
+pub const HELPABLES_BUILTINS: [&str; 8] = [
+ "cat - display the contents of a present file",
+ "config - manipulate the configuration",
+ "echo - display a line of predefined text",
+ "exit - end the process",
+ "fetch - a neofetch like utility loosely based on rfetch",
+ "help - you are here",
+ "history - display the command history",
+ "ls - display the present files",
+];
+pub const HELPABLES_BUILTIN_CONFIG: [&str; 3] = [
+ "help - you are here",
+ "refresh - reload the configuration file",
+ "show - display the current configuration",
+];
diff --git a/whirl_prompt/src/lib.rs b/whirl_prompt/src/lib.rs
index 613c507..15f40aa 100644
--- a/whirl_prompt/src/lib.rs
+++ b/whirl_prompt/src/lib.rs
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
mod builtins;
+mod constants;
mod structure;
use std::{io, io::Write, str::FromStr};