Include keys.json as static data
This commit is contained in:
parent
bd51609f05
commit
ca8e830f0a
1 changed files with 21 additions and 14 deletions
27
src/cli.rs
27
src/cli.rs
|
@ -6,7 +6,7 @@ use openssl::{
|
||||||
bn::{BigNum, MsbOption},
|
bn::{BigNum, MsbOption},
|
||||||
ec::{EcGroup, EcPoint},
|
ec::{EcGroup, EcPoint},
|
||||||
};
|
};
|
||||||
use serde_json::from_reader;
|
use serde_json::{from_reader, from_str};
|
||||||
|
|
||||||
use crate::{bink1998, crypto::initialize_elliptic_curve};
|
use crate::{bink1998, crypto::initialize_elliptic_curve};
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ pub struct Options {
|
||||||
num_keys: i32,
|
num_keys: i32,
|
||||||
|
|
||||||
/// Specify which keys file to load
|
/// Specify which keys file to load
|
||||||
#[arg(short = 'f', long = "file", default_value = "keys.json")]
|
#[arg(short = 'f', long = "file")]
|
||||||
keys_filename: String,
|
keys_filename: Option<String>,
|
||||||
|
|
||||||
/// Installation ID used to generate confirmation ID
|
/// Installation ID used to generate confirmation ID
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
|
@ -137,21 +137,28 @@ impl Cli {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_command_line(options: &mut Options) -> Result<serde_json::Value> {
|
fn validate_command_line(options: &mut Options) -> Result<serde_json::Value> {
|
||||||
|
let keys = {
|
||||||
|
if let Some(filename) = &options.keys_filename {
|
||||||
if options.verbose {
|
if options.verbose {
|
||||||
println!("Loading keys file {}", options.keys_filename);
|
println!("Loading keys file {}", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
let keys = Self::load_json(&options.keys_filename)?;
|
let keys = Self::load_json(filename)?;
|
||||||
|
|
||||||
if options.verbose {
|
if options.verbose {
|
||||||
println!("Loaded keys from {} successfully", options.keys_filename);
|
println!("Loaded keys from {} successfully", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys
|
||||||
|
} else {
|
||||||
|
from_str(std::include_str!("../keys.json"))?
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if options.list {
|
if options.list {
|
||||||
let products = keys["Products"].as_object().ok_or(anyhow!(
|
let products = keys["Products"]
|
||||||
"`Products` object not found in {}",
|
.as_object()
|
||||||
options.keys_filename
|
.ok_or(anyhow!("`Products` object not found in keys",))?;
|
||||||
))?;
|
|
||||||
for (key, value) in products.iter() {
|
for (key, value) in products.iter() {
|
||||||
println!("{}: {}", key, value["BINK"]);
|
println!("{}: {}", key, value["BINK"]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue