forked from eclipse-kuksa/kuksa-incubation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sebastian Schildt <sebastian.schildt@de.bosch.com>
- Loading branch information
1 parent
f70153a
commit 89f9943
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "kuksa-persistence-provider" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "4.5.20", features = ["derive"] } | ||
tinyjson = "2.5.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"restore-only": [ | ||
"Vehicle.Speed", | ||
"Vehicle.Engine.RPM" | ||
], | ||
"restore-and-watch": [ | ||
"Vehicle.D", | ||
"Vehicle.X" | ||
], | ||
"state-storage": { | ||
"type": "file", | ||
"path": "state.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
use std::path::PathBuf; | ||
use clap::Parser; | ||
use tinyjson::JsonValue; | ||
|
||
#[derive(Parser)] | ||
#[command(version, about, long_about = None)] | ||
struct CmdLine { | ||
/// JSON file containing the configuration | ||
#[arg(short, long, value_name = "FILE")] | ||
config: Option<PathBuf>, | ||
|
||
/// Turn debugging information on | ||
#[arg(short, long, action = clap::ArgAction::Count)] | ||
debug: u8, | ||
} | ||
|
||
fn main() { | ||
let args = CmdLine::parse(); | ||
|
||
let config = args.config.unwrap_or_else(|| PathBuf::from("config.json")); | ||
|
||
//Check config exists | ||
if !config.exists() { | ||
eprintln!("Error: Can not find configuration at {}", config.display()); | ||
std::process::exit(1); | ||
} | ||
|
||
println!("Reading configuration from: {}", config.display()); | ||
// Reading configuration file into a string | ||
let config_str = std::fs::read_to_string(config).unwrap(); | ||
|
||
println!("Configuration: {}", config_str); | ||
|
||
let parsed: JsonValue = config_str.parse().unwrap(); | ||
println!("Parsed: {:?}", parsed); | ||
|
||
|
||
|
||
println!("Hello, world!"); | ||
} |