Merge pull request #763 from matthiasbeyer/imag-view/implement-default-functionality
imag-view: implement default functionality
This commit is contained in:
commit
c6e32a4fa8
2 changed files with 24 additions and 25 deletions
|
@ -48,14 +48,6 @@ fn main() {
|
||||||
let view_header = rt.cli().is_present("view-header");
|
let view_header = rt.cli().is_present("view-header");
|
||||||
let view_content = rt.cli().is_present("view-content");
|
let view_content = rt.cli().is_present("view-content");
|
||||||
|
|
||||||
let scmd = match rt.cli().subcommand_matches("view-in") {
|
|
||||||
None => {
|
|
||||||
debug!("No commandline call");
|
|
||||||
exit(1); // we can afford not-executing destructors here
|
|
||||||
}
|
|
||||||
Some(s) => s,
|
|
||||||
};
|
|
||||||
|
|
||||||
let entry = match rt.store().get(PathBuf::from(entry_id)) {
|
let entry = match rt.store().get(PathBuf::from(entry_id)) {
|
||||||
Ok(Some(fle)) => fle,
|
Ok(Some(fle)) => fle,
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
|
@ -68,19 +60,27 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = {
|
let res = {
|
||||||
if scmd.is_present("view-in-stdout") {
|
match rt.cli().subcommand_matches("view-in") {
|
||||||
} else if scmd.is_present("view-in-ui") {
|
None => {
|
||||||
warn!("Viewing in UI is currently not supported, switch to stdout");
|
debug!("No commandline call");
|
||||||
} else if scmd.is_present("view-in-browser") {
|
debug!("Assuming to view in cli (stdout)");
|
||||||
warn!("Viewing in browser is currently not supported, switch to stdout");
|
},
|
||||||
} else if scmd.is_present("view-in-texteditor") {
|
Some(s) => {
|
||||||
if let Err(e) = Editor::new(&rt, &entry).show() {
|
if s.is_present("view-in-stdout") {
|
||||||
error!("Cannot view in editor: {}", e);
|
} else if s.is_present("view-in-ui") {
|
||||||
trace_error_exit(&e, 1);
|
warn!("Viewing in UI is currently not supported, switch to stdout");
|
||||||
}
|
} else if s.is_present("view-in-browser") {
|
||||||
} else if scmd.is_present("view-in-custom") {
|
warn!("Viewing in browser is currently not supported, switch to stdout");
|
||||||
warn!("Viewing in custom is currently not supported, switch to stdout");
|
} else if s.is_present("view-in-texteditor") {
|
||||||
}
|
if let Err(e) = Editor::new(&rt, &entry).show() {
|
||||||
|
error!("Cannot view in editor: {}", e);
|
||||||
|
trace_error_exit(&e, 1);
|
||||||
|
}
|
||||||
|
} else if s.is_present("view-in-custom") {
|
||||||
|
warn!("Viewing in custom is currently not supported, switch to stdout");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
StdoutViewer::new(view_header, view_content).view_entry(&entry)
|
StdoutViewer::new(view_header, view_content).view_entry(&entry)
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,12 +50,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.value_name("BROWSER"))
|
.value_name("BROWSER"))
|
||||||
|
|
||||||
.arg(Arg::with_name("view-in-texteditor")
|
.arg(Arg::with_name("view-in-texteditor")
|
||||||
.long("editor")
|
.long("in-editor")
|
||||||
.short("e")
|
.short("e")
|
||||||
.takes_value(true) // optional, which editor
|
.takes_value(false)
|
||||||
.required(false)
|
.required(false)
|
||||||
.help("View content in $EDITOR")
|
.help("View content in $EDITOR (can be passed via --editor)"))
|
||||||
.value_name("EDITOR"))
|
|
||||||
|
|
||||||
.arg(Arg::with_name("view-in-custom")
|
.arg(Arg::with_name("view-in-custom")
|
||||||
.long("custom")
|
.long("custom")
|
||||||
|
|
Loading…
Reference in a new issue