Migrate away from structopt
Clap 3 supports derive natively, so we don't need structopt anymore
(since it was based on clap 2).
Besides, sort the arguments to make positional ones first.
Bug: 246385183
Test: atest AuthFsHostTest ComposHostTestCases MicrodroidTestCase
Change-Id: I75e25ffcb63bf717be8deb9720e0fdf78a0c7ccf
diff --git a/microdroid/initrd/src/main.rs b/microdroid/initrd/src/main.rs
index 1023a40..69c6ae4 100644
--- a/microdroid/initrd/src/main.rs
+++ b/microdroid/initrd/src/main.rs
@@ -14,26 +14,23 @@
//! Append bootconfig to initrd image
use anyhow::Result;
-
+use clap::Parser;
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
-use structopt::StructOpt;
const FOOTER_ALIGNMENT: usize = 4;
const ZEROS: [u8; 4] = [0u8; 4_usize];
-#[derive(StructOpt, Debug)]
+#[derive(Parser, Debug)]
struct Args {
- /// Output
- #[structopt(parse(from_os_str), long = "output")]
- output: PathBuf,
/// Initrd (without bootconfig)
- #[structopt(parse(from_os_str))]
initrd: PathBuf,
/// Bootconfig
- #[structopt(parse(from_os_str))]
bootconfigs: Vec<PathBuf>,
+ /// Output
+ #[clap(long = "output")]
+ output: PathBuf,
}
fn get_checksum(file_path: &PathBuf) -> Result<u32> {
@@ -67,7 +64,7 @@
}
fn try_main() -> Result<()> {
- let args = Args::from_args_safe()?;
+ let args = Args::parse();
attach_bootconfig(args.initrd, args.bootconfigs, args.output)?;
Ok(())
}