forked from xcambar/purs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
51 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
use clap::{ArgMatches, App, SubCommand, Arg}; | ||
use clap::{App, Arg, ArgMatches, SubCommand}; | ||
|
||
const INSERT_SYMBOL:&str = "❯"; | ||
const COMMAND_SYMBOL:&str = "⬢"; | ||
const COMMAND_KEYMAP:&str = "vicmd"; | ||
const NO_ERROR:&str = "0"; | ||
const INSERT_SYMBOL: &str = "→"; | ||
const COMMAND_SYMBOL: &str = "⬢"; | ||
const COMMAND_KEYMAP: &str = "vicmd"; | ||
const NO_ERROR: &str = "0"; | ||
|
||
pub fn display(sub_matches: &ArgMatches) { | ||
let last_return_code = sub_matches.value_of("last_return_code").unwrap_or("0"); | ||
let keymap = sub_matches.value_of("keymap").unwrap_or("US"); | ||
|
||
let symbol = match keymap { | ||
COMMAND_KEYMAP => COMMAND_SYMBOL, | ||
_ => INSERT_SYMBOL, | ||
}; | ||
let last_return_code = sub_matches.value_of("last_return_code").unwrap_or("0"); | ||
let keymap = sub_matches.value_of("keymap").unwrap_or("US"); | ||
|
||
let shell_color = match (symbol, last_return_code) { | ||
(COMMAND_SYMBOL, _) => 3, | ||
(_, NO_ERROR) => 5, | ||
_ => 9, | ||
}; | ||
let symbol = match keymap { | ||
COMMAND_KEYMAP => COMMAND_SYMBOL, | ||
_ => INSERT_SYMBOL, | ||
}; | ||
|
||
print!("%F{{{}}}{}%f ", shell_color, symbol); | ||
let shell_color = match (symbol, last_return_code) { | ||
(COMMAND_SYMBOL, _) => 3, | ||
(_, NO_ERROR) => 5, | ||
_ => 9, | ||
}; | ||
|
||
print!("%F{{{}}}{}%f ", shell_color, symbol); | ||
} | ||
|
||
pub fn cli_arguments<'a>() -> App<'a, 'a> { | ||
SubCommand::with_name("prompt") | ||
.arg( | ||
Arg::with_name("last_return_code") | ||
.short("r") | ||
.takes_value(true) | ||
) | ||
.arg( | ||
Arg::with_name("keymap") | ||
.short("k") | ||
.takes_value(true) | ||
) | ||
SubCommand::with_name("prompt") | ||
.arg( | ||
Arg::with_name("last_return_code") | ||
.short("r") | ||
.takes_value(true), | ||
) | ||
.arg(Arg::with_name("keymap").short("k").takes_value(true)) | ||
} |