Skip to content

Commit

Permalink
test: use argh for parsing cmdline parameters
Browse files Browse the repository at this point in the history
Use argh for parsing cmdline parameters, instead of manually getting
them.
  • Loading branch information
dongsupark committed Oct 18, 2023
1 parent ecabc67 commit fd96793
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/crau_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ use std::fs;

use update_format_crau::delta_update;

use argh::FromArgs;

const PUBKEY_FILE: &str = "../src/testdata/public_key_test_pkcs8.pem";

#[derive(FromArgs, Debug)]
/// A test program for verifying CRAU header of update payloads.
struct Args {
/// source payload path
#[argh(option, short = 's')]
src_path: String,

/// destination signature path
#[argh(option, short = 'd')]
sig_path: String,
}

fn main() -> Result<(), Box<dyn Error>> {
// TODO: parse args using a decent command-line parameter framework
let srcpath = std::env::args().nth(1).expect("missing source payload path (second argument)");
let sigpath = std::env::args().nth(2).expect("missing destination signature path (third argument)");
let args: Args = argh::from_env();

let srcpath = &args.src_path;
let sigpath = &args.sig_path;

// Read update payload from srcpath, read delta update header from the payload.
let upfile = fs::File::open(srcpath.clone())?;
Expand Down

0 comments on commit fd96793

Please sign in to comment.