Skip to content

Commit

Permalink
upd result type
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvanbenthem committed Jul 4, 2023
1 parent 7935ec9 commit de3cd3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions project/example-var.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
policy_name: test-policy
pool_name: poc-pool
4 changes: 3 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
cargo test
cargo build
# run example to stdout
cat project/example-var.json | ./target/debug/manifestgen --template project/targets.tmpl
cat project/example-var.json | ./target/debug/manifestgen --template project/targets.tmpl
#cat project/example-var.yaml | ./target/debug/manifestgen --template project/targets.tmpl
8 changes: 3 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ use clap::{App, Arg};
#[derive(Debug, Deserialize, Serialize)]
struct KeyValuePairs(BTreeMap<String, String>);

type MyResult<T> = Result<T, Box<dyn Error>>;

#[derive(Debug)]
struct Config {
template_file: String,
output_file: String,
json_file: String,
}

fn main() -> MyResult<()> {
fn main() -> Result<(), Box<dyn Error>> {
// Get command-line arguments
let config = get_args().unwrap();

Expand Down Expand Up @@ -59,7 +57,7 @@ fn main() -> MyResult<()> {
}

// --------------------------------------------------
fn get_args() -> MyResult<Config> {
fn get_args() -> Result<Config, Box<dyn Error>> {
// Define and parse command-line arguments using clap
let matches = App::new("Template Renderer")
.arg(
Expand Down Expand Up @@ -96,7 +94,7 @@ fn get_args() -> MyResult<Config> {
}

// --------------------------------------------------
fn manifest_writer(output: &String, template: &String) -> MyResult<()> {
fn manifest_writer(output: &String, template: &String) -> Result<(), Box<dyn Error>> {
if output.is_empty() {
// Get the stdout handle
let stdout = io::stdout();
Expand Down

0 comments on commit de3cd3e

Please sign in to comment.