Skip to content

Commit 23f00ec

Browse files
m0veaxorangecms
authored andcommitted
extract-dtb: simplify command
- use positional arguments - set default destination path to current directory
1 parent d07a525 commit 23f00ec

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

extract-dtb/main.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ const DTB_MAGIC: u32 = 0xd00d_feed;
1111
#[command(author, version, about, long_about = None)]
1212
struct Args {
1313
/// Filename
14-
#[arg(short, long)]
14+
#[arg(required = true)]
1515
filename: String,
16-
#[arg(short, long)]
16+
#[arg(required = false)]
1717
dest: String,
1818
}
1919

2020
fn main() {
2121
let args = Args::parse();
2222
let filename = args.filename;
23-
let dest = args.dest;
23+
24+
let dest = if args.dest.is_empty() {
25+
String::from("./")
26+
} else {
27+
String::from(args.dest)
28+
};
2429

2530
let mut f = File::open(filename).unwrap();
2631
let step = 8;
@@ -44,7 +49,7 @@ fn main() {
4449
let mut buf = vec![0; size];
4550
f.read_exact(&mut buf).unwrap();
4651

47-
let dt = DT::load(&buf).unwrap();
52+
let _dt = DT::load(&buf).unwrap();
4853

4954
// does it exist? if not, rule 34
5055
fs::create_dir_all(&dest).unwrap();

0 commit comments

Comments
 (0)