mirror of
https://github.com/sharkdp/bat
synced 2024-11-18 15:26:16 +00:00
commit
1692e5fef7
@ -8,11 +8,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
AppSettings::ColorNever
|
AppSettings::ColorNever
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if the current directory contains a file name cache, if it does
|
let app = ClapApp::new(crate_name!())
|
||||||
// do not make the arguements for subcommand 'cache' required.
|
|
||||||
let arg_group_required = !Path::new("cache").exists();
|
|
||||||
|
|
||||||
ClapApp::new(crate_name!())
|
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.global_setting(clap_color_setting)
|
.global_setting(clap_color_setting)
|
||||||
.global_setting(AppSettings::DeriveDisplayOrder)
|
.global_setting(AppSettings::DeriveDisplayOrder)
|
||||||
@ -380,7 +376,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.hidden(true)
|
.hidden(true)
|
||||||
.help("Show bat's cache directory."),
|
.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")
|
SubCommand::with_name("cache")
|
||||||
.about("Modify the syntax-definition and theme cache")
|
.about("Modify the syntax-definition and theme cache")
|
||||||
.arg(
|
.arg(
|
||||||
@ -402,7 +406,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|||||||
.group(
|
.group(
|
||||||
ArgGroup::with_name("cache-actions")
|
ArgGroup::with_name("cache-actions")
|
||||||
.args(&["build", "clear"])
|
.args(&["build", "clear"])
|
||||||
.required(arg_group_required),
|
.required(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("source")
|
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.",
|
"Use a different directory to store the cached syntax and theme set.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(Arg::with_name("blank").long("blank").requires("build").help(
|
.arg(
|
||||||
|
Arg::with_name("blank")
|
||||||
|
.long("blank")
|
||||||
|
.requires("build")
|
||||||
|
.help(
|
||||||
"Create completely new syntax and theme sets \
|
"Create completely new syntax and theme sets \
|
||||||
(instead of appending to the default 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("");
|
.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]
|
#[test]
|
||||||
fn can_print_file_starting_with_cache() {
|
fn can_print_file_starting_with_cache() {
|
||||||
bat_with_config()
|
bat_with_config()
|
||||||
|
Loading…
Reference in New Issue
Block a user