Skip to content

Commit c19a8e4

Browse files
committed
feat: added cli implementation
1 parent 875f864 commit c19a8e4

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

arinc-explorer/src/loads/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ mod tests {
172172
// 4 hex = 16 bits = 2 bytes
173173
let file = PathBuf::from("../test-data/LOADS.LUM");
174174
let loads_lum = LoadsLum::new(file.as_path()).unwrap();
175+
println!("{loads_lum}");
175176

176177
assert_eq!(loads_lum.get_file_length(), 39);
177178
assert_eq!(loads_lum.media_file_format_verion, 0x8002);
@@ -187,7 +188,5 @@ mod tests {
187188
assert_eq!(loads_lum.loads.len(), 1);
188189
assert_eq!(loads_lum.user_defined_data, None);
189190
assert_eq!(loads_lum.file_crc, 0x5246);
190-
191-
println!("{loads_lum}");
192191
}
193192
}

cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ keywords.workspace = true
1414
publish = false
1515

1616
[dependencies]
17+
anyhow = "1.0.98"
1718
arinc-explorer = { path = "../arinc-explorer" }
1819
clap = { version = "4.5.3", features = ["derive"] }
20+
exitcode = "1.1.2"

cli/src/main.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::path::PathBuf;
2+
use std::process;
23

4+
use arinc_explorer::loads::LoadsLum;
35
use clap::Parser;
6+
use exitcode::{OK, SOFTWARE};
47

58
#[derive(Clone, Parser, Debug)]
69
pub struct Args {
@@ -9,5 +12,22 @@ pub struct Args {
912
}
1013

1114
fn main() {
12-
println!("Hello, world!");
15+
let args = Args::parse();
16+
17+
match run(args) {
18+
Ok(()) => process::exit(OK),
19+
Err(e) => {
20+
eprintln!("Internal software error: {e}");
21+
process::exit(SOFTWARE);
22+
}
23+
}
24+
}
25+
26+
fn run(args: Args) -> anyhow::Result<()> {
27+
let filename = args.filename;
28+
29+
let loads_lum = LoadsLum::new(&filename)?;
30+
println!("{loads_lum}");
31+
32+
Ok(())
1333
}

0 commit comments

Comments
 (0)