Merge pull request #1347 from matthiasbeyer/imag-ids/prefix

imag-ids: prefix printing off by default
This commit is contained in:
Matthias Beyer 2018-03-17 00:34:00 +01:00 committed by GitHub
commit 1d3994d108
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -40,7 +40,7 @@ extern crate libimagstore;
use std::io::Write; use std::io::Write;
use clap::App; use clap::{Arg, App};
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
use libimagerror::trace::MapErrTrace; use libimagerror::trace::MapErrTrace;
@ -51,6 +51,12 @@ use libimagerror::io::ToExitCode;
/// No special CLI /// No special CLI
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
app app
.arg(Arg::with_name("print-storepath")
.long("with-storepath")
.takes_value(false)
.required(false)
.multiple(false)
.help("Print the storepath for each id"))
} }
fn main() { fn main() {
@ -60,9 +66,16 @@ fn main() {
"print all ids", "print all ids",
build_ui); build_ui);
let print_storepath = rt.cli().is_present("print-storepath");
rt.store() rt.store()
.entries() .entries()
.map_err_trace_exit_unwrap(1) .map_err_trace_exit_unwrap(1)
.map(|id| if print_storepath {
id
} else {
id.without_base()
})
.for_each(|id| { .for_each(|id| {
let _ = writeln!(rt.stdout(), "{}", id.to_str().map_err_trace_exit_unwrap(1)) let _ = writeln!(rt.stdout(), "{}", id.to_str().map_err_trace_exit_unwrap(1))
.to_exit_code() .to_exit_code()

View file

@ -41,6 +41,8 @@ This section contains the changelog from the last release to the next release.
output as JSON. output as JSON.
* `imag-edit` can now read store ids from stdin, sorts * `imag-edit` can now read store ids from stdin, sorts
`imag ids | fzf | imag edit -I` is not a thing. `imag ids | fzf | imag edit -I` is not a thing.
* `imag ids` does not print the path of the store. Can be turned on using
commandline flag.
* Minor changes * Minor changes
* A license-checker was included into the CI setup, which checks whether all * A license-checker was included into the CI setup, which checks whether all
".rs"-files have the license header at the top of the file ".rs"-files have the license header at the top of the file