cli readme and default creds path

This commit is contained in:
mbecker20
2024-05-09 22:29:40 -07:00
parent caac3fdcc4
commit cb8ad90838
2 changed files with 27 additions and 4 deletions

View File

@@ -1,8 +1,19 @@
# monitor CLI
# Monitor CLI
Monitor CLI is a command line tool to sync monitor resources and execute file defined procedures.
## Examples
## Usage
Configure a file `~/.config/monitor/creds.toml` file with contents:
```toml
url = "https://your.monitor.address"
key = "YOUR-API-KEY"
secret = "YOUR-API-SECRET"
```
Note. You can specify a different creds file by using `--creds ./other/path.toml`.
With your creds in place, you can run syncs:
```sh
## Sync resources in a single file
@@ -15,6 +26,8 @@ monitor sync ./resources
monitor sync
```
And executions:
```sh
## Execute a TOML defined procedure
monitor exec ./execution/execution.toml

View File

@@ -38,7 +38,7 @@ enum Command {
Sync {
/// The path of the resource folder / file
/// Folder paths will recursively incorporate all the resources it finds under the folder
#[arg(default_value_t = String::from("./resources"))]
#[arg(default_value_t = default_path())]
path: String,
},
@@ -49,6 +49,12 @@ enum Command {
},
}
fn default_path() -> String {
let home = std::env::var("HOME")
.expect("no HOME env var. cannot get default config path.");
format!("{home}/.config/monitor/creds.toml")
}
#[derive(Debug, Deserialize)]
struct CredsFile {
url: String,
@@ -94,7 +100,11 @@ fn parse_toml_file<T: DeserializeOwned>(
}
fn wait_for_enter(press_enter_to: &str) -> anyhow::Result<()> {
println!("\nPress {} to {}\n", "ENTER".green(), press_enter_to.bold());
println!(
"\nPress {} to {}\n",
"ENTER".green(),
press_enter_to.bold()
);
let buffer = &mut [0u8];
std::io::stdin()
.read_exact(buffer)