Skip to content

Commit bea10a5

Browse files
committed
extract-dtb: simplify command
- use positional arguments - set default destination path to current directory
1 parent 7f46144 commit bea10a5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

extract-dtb/main.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@ 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+
println!("{:?}", args.dest);
25+
26+
let dest = if args.dest.is_empty() {
27+
String::from("./")
28+
} else {
29+
String::from(args.dest)
30+
};
31+
32+
println!("{:?}", dest);
2433

2534
let mut f = File::open(filename).unwrap();
2635
let step = 8;
@@ -44,7 +53,7 @@ fn main() {
4453
let mut buf = vec![0; size];
4554
f.read_exact(&mut buf).unwrap();
4655

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

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

0 commit comments

Comments
 (0)