summaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-02-26 20:59:27 +0100
committerCanop <cano.petrole@gmail.com>2021-02-26 20:59:27 +0100
commit8d5ae36e67a60af6a752ca56880ff9c2e7cf1e92 (patch)
tree97d68bb2ce2ca1ce766874a5de81a4e1a4a4f805 /src/cli
parent552f0f5b6eed0b1051cbb910cb2eb48a1531141d (diff)
obey `--color no` even in application mode
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/mod.rs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 78e32eb..7fe9441 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -79,17 +79,6 @@ fn is_output_piped() -> bool {
!stdout().is_tty()
}
-fn is_no_style(cli_matches: &ArgMatches) -> bool {
- if cli_matches.is_present("no-style") {
- return true;
- }
- match cli_matches.value_of("color") {
- Some("yes") => false,
- Some("no") => true,
- _ => is_output_piped(),
- }
-}
-
/// run the application, and maybe return a launchable
/// which must be run after broot
pub fn run() -> Result<Option<Launchable>, ProgramError> {
@@ -159,7 +148,17 @@ pub fn run() -> Result<Option<Launchable>, ProgramError> {
let file_export_path = cli_matches.value_of("file-export-path").map(str::to_string);
let cmd_export_path = cli_matches.value_of("cmd-export-path").map(str::to_string);
let commands = cli_matches.value_of("commands").map(str::to_string);
- let no_style = is_no_style(&cli_matches);
+ let (no_style, must_show_selection_mark) = {
+ if cli_matches.is_present("no-style") {
+ (true, is_output_piped())
+ } else {
+ match cli_matches.value_of("color") {
+ Some("yes") => (false, false),
+ Some("no") => (true, !is_output_piped()),
+ _ => (is_output_piped(), false),
+ }
+ }
+ };
let height = cli_matches.value_of("height").and_then(|s| s.parse().ok());
let root = get_root_path(&cli_matches)?;
@@ -184,7 +183,7 @@ pub fn run() -> Result<Option<Launchable>, ProgramError> {
return Ok(None);
}
- let launch_args = AppLaunchArgs {
+ let mut launch_args = AppLaunchArgs {
root,
file_export_path,
cmd_export_path,
@@ -196,6 +195,9 @@ pub fn run() -> Result<Option<Launchable>, ProgramError> {
#[cfg(feature = "client-server")]
listen: cli_matches.value_of("listen").map(str::to_string),
};
+ if must_show_selection_mark {
+ launch_args.tree_options.show_selection_mark = true;
+ }
let context = AppContext::from(launch_args, verb_store, &config)?;
let mut w = display::writer();