Allow specifying target at runtime

The cookbook could be used to build for multiple architectures, if that
is ever supported.
parent e8ed1b08
......@@ -87,10 +87,11 @@ fn upgrade(repo: Repo) -> io::Result<()> {
}
fn main() {
let repo = Repo::new(env!("TARGET"));
let matches = App::new("pkg")
.subcommand(SubCommand::with_name("clean")
.arg(Arg::with_name("target")
.long("target")
.takes_value(true)
).subcommand(SubCommand::with_name("clean")
.arg(Arg::with_name("package")
.multiple(true)
.required(true)
......@@ -128,6 +129,13 @@ fn main() {
).subcommand(SubCommand::with_name("upgrade")
).get_matches();
let target = matches.value_of("target")
.or(option_env!("TARGET"))
.expect(concat!("pkg was not compiled with a target, ",
"and --target was not specified"));
let repo = Repo::new(target);
match matches.subcommand() {
("clean", Some(m)) => {
for package in m.values_of("package").unwrap() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment