mirror of
https://github.com/sharkdp/bat
synced 2024-11-24 04:43:07 +00:00
commit
1692e5fef7
2 changed files with 32 additions and 13 deletions
|
@ -8,11 +8,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||
AppSettings::ColorNever
|
||||
};
|
||||
|
||||
// Check if the current directory contains a file name cache, if it does
|
||||
// do not make the arguements for subcommand 'cache' required.
|
||||
let arg_group_required = !Path::new("cache").exists();
|
||||
|
||||
ClapApp::new(crate_name!())
|
||||
let app = ClapApp::new(crate_name!())
|
||||
.version(crate_version!())
|
||||
.global_setting(clap_color_setting)
|
||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||
|
@ -380,7 +376,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||
.hidden(true)
|
||||
.help("Show bat's cache directory."),
|
||||
)
|
||||
.subcommand(
|
||||
.help_message("Print this help message.")
|
||||
.version_message("Show version information.");
|
||||
|
||||
// Check if the current directory contains a file name cache. Otherwise,
|
||||
// enable the 'bat cache' subcommand.
|
||||
if Path::new("cache").exists() {
|
||||
app
|
||||
} else {
|
||||
app.subcommand(
|
||||
SubCommand::with_name("cache")
|
||||
.about("Modify the syntax-definition and theme cache")
|
||||
.arg(
|
||||
|
@ -402,7 +406,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||
.group(
|
||||
ArgGroup::with_name("cache-actions")
|
||||
.args(&["build", "clear"])
|
||||
.required(arg_group_required),
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("source")
|
||||
|
@ -422,11 +426,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||
"Use a different directory to store the cached syntax and theme set.",
|
||||
),
|
||||
)
|
||||
.arg(Arg::with_name("blank").long("blank").requires("build").help(
|
||||
"Create completely new syntax and theme sets \
|
||||
(instead of appending to the default sets).",
|
||||
)),
|
||||
.arg(
|
||||
Arg::with_name("blank")
|
||||
.long("blank")
|
||||
.requires("build")
|
||||
.help(
|
||||
"Create completely new syntax and theme sets \
|
||||
(instead of appending to the default sets).",
|
||||
),
|
||||
),
|
||||
)
|
||||
.help_message("Print this help message.")
|
||||
.version_message("Show version information.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -459,6 +459,17 @@ fn can_print_file_named_cache() {
|
|||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_print_file_named_cache_with_additional_argument() {
|
||||
bat_with_config()
|
||||
.arg("cache")
|
||||
.arg("test.txt")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout("test\nhello world\n")
|
||||
.stderr("");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_print_file_starting_with_cache() {
|
||||
bat_with_config()
|
||||
|
|
Loading…
Reference in a new issue