Allow --id / -i as path specification, for consistency
This commit is contained in:
parent
a59ce2003c
commit
04a5bb9138
3 changed files with 36 additions and 2 deletions
|
@ -4,6 +4,9 @@ use std::fs::OpenOptions;
|
||||||
use std::result::Result as RResult;
|
use std::result::Result as RResult;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::io::stderr;
|
||||||
|
use std::process::exit;
|
||||||
|
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
|
|
||||||
|
@ -25,7 +28,14 @@ pub fn create(rt: &Runtime) {
|
||||||
debug!("Found 'create' subcommand...");
|
debug!("Found 'create' subcommand...");
|
||||||
|
|
||||||
// unwrap is safe as value is required
|
// unwrap is safe as value is required
|
||||||
let path = build_entry_path(rt, scmd.value_of("path").unwrap());
|
let path = scmd.value_of("path").or_else(|| scmd.value_of("id"));
|
||||||
|
if path.is_none() {
|
||||||
|
warn!("No ID / Path provided. Exiting now");
|
||||||
|
write!(stderr(), "No ID / Path provided. Exiting now");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = build_entry_path(rt, path.unwrap());
|
||||||
debug!("path = {:?}", path);
|
debug!("path = {:?}", path);
|
||||||
|
|
||||||
if scmd.subcommand_matches("entry").is_some() {
|
if scmd.subcommand_matches("entry").is_some() {
|
||||||
|
|
|
@ -8,8 +8,14 @@ pub fn build_ui<'a>(app: App<'a, 'a, 'a, 'a, 'a, 'a>) -> App<'a, 'a, 'a, 'a, 'a,
|
||||||
.long("path")
|
.long("path")
|
||||||
.short("p")
|
.short("p")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.required(true)
|
.required(false)
|
||||||
.help("Create at this store path"))
|
.help("Create at this store path"))
|
||||||
|
.arg(Arg::with_name("id")
|
||||||
|
.long("id")
|
||||||
|
.short("i")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(false)
|
||||||
|
.help("Same as --path, for consistency"))
|
||||||
.arg(Arg::with_name("from-raw")
|
.arg(Arg::with_name("from-raw")
|
||||||
.long("from-raw")
|
.long("from-raw")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
|
|
|
@ -10,6 +10,22 @@ test_call() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_call_id() {
|
||||||
|
imag-store create -i /test-call~0.1.0
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
err "Return value should be zero, was non-zero"
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test_call_no_id() {
|
||||||
|
imag-store create
|
||||||
|
if [[ ! $? -eq 1 ]]; then
|
||||||
|
err "Return value should be zero, was non-zero"
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
test_mkstore() {
|
test_mkstore() {
|
||||||
imag-store create -p /test-mkstore~0.1.0 || { err "Calling imag failed"; return 1; }
|
imag-store create -p /test-mkstore~0.1.0 || { err "Calling imag failed"; return 1; }
|
||||||
if [[ -d ${STORE} ]]; then
|
if [[ -d ${STORE} ]]; then
|
||||||
|
@ -147,6 +163,8 @@ EOS
|
||||||
|
|
||||||
invoke_tests \
|
invoke_tests \
|
||||||
test_call \
|
test_call \
|
||||||
|
test_call_id \
|
||||||
|
test_call_no_id \
|
||||||
test_mkstore \
|
test_mkstore \
|
||||||
test_std_header \
|
test_std_header \
|
||||||
test_std_header_plus_custom \
|
test_std_header_plus_custom \
|
||||||
|
|
Loading…
Reference in a new issue