mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
Fix: Show A Message such that the user will know there is something wrong (#1092)
* Fix: Show A Message such that the user will know there is something wrong Fixes #31 * Update main.rs * Apply suggestions from code review Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
env,
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{stdin, stdout},
|
io::{stdin, stdout},
|
||||||
path::Path,
|
path::Path,
|
||||||
@@ -19,6 +20,10 @@ use config::{
|
|||||||
apply_dependency_configuration, validate_configuration, validate_dependency_configuration,
|
apply_dependency_configuration, validate_configuration, validate_dependency_configuration,
|
||||||
};
|
};
|
||||||
use embassy::config::action::ConfigRes;
|
use embassy::config::action::ConfigRes;
|
||||||
|
use serde_json::json;
|
||||||
|
|
||||||
|
const PROPERTIES_FALLBACK_MESSAGE: &str =
|
||||||
|
"Could not find properties. The service might still be starting";
|
||||||
pub enum CompatRes {
|
pub enum CompatRes {
|
||||||
SetResult,
|
SetResult,
|
||||||
ConfigRes,
|
ConfigRes,
|
||||||
@@ -155,6 +160,10 @@ fn inner_main() -> Result<(), anyhow::Error> {
|
|||||||
Arg::with_name("mountpoint")
|
Arg::with_name("mountpoint")
|
||||||
.help("The data directory of the service to mount to.")
|
.help("The data directory of the service to mount to.")
|
||||||
.required(true),
|
.required(true),
|
||||||
|
).arg(
|
||||||
|
Arg::with_name("fallbackMessage")
|
||||||
|
.help("The message to indicate that the startup is still working, or stats.yaml couldn't be found")
|
||||||
|
.required(false),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
let matches = app.get_matches();
|
let matches = app.get_matches();
|
||||||
@@ -295,7 +304,22 @@ fn inner_main() -> Result<(), anyhow::Error> {
|
|||||||
let stats: serde_json::Value = if stats_path.exists() {
|
let stats: serde_json::Value = if stats_path.exists() {
|
||||||
serde_yaml::from_reader(File::open(stats_path).unwrap()).unwrap()
|
serde_yaml::from_reader(File::open(stats_path).unwrap()).unwrap()
|
||||||
} else {
|
} else {
|
||||||
serde_json::Value::from("{}")
|
let fallbackMessage: &str = sub_m
|
||||||
|
.value_of("fallbackMessage")
|
||||||
|
.unwrap_or_else(|| PROPERTIES_FALLBACK_MESSAGE);
|
||||||
|
json!({
|
||||||
|
"version": 2i64,
|
||||||
|
"data": {
|
||||||
|
"Not Ready": {
|
||||||
|
"type": "string",
|
||||||
|
"value": fallbackMessage,
|
||||||
|
"qr": false,
|
||||||
|
"copyable": false,
|
||||||
|
"masked": false,
|
||||||
|
"description":"Fallback Message When Properties could not be found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
};
|
};
|
||||||
serde_json::to_writer(stdout(), &stats)?;
|
serde_json::to_writer(stdout(), &stats)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user