mirror of
https://github.com/moghtech/komodo.git
synced 2026-04-29 12:43:26 -05:00
cli readme and default creds path
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user