@@ -8,11 +8,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
88 AppSettings::ColorNever
99 };
1010
11− // Check if the current directory contains a file name cache, if it does
12− // do not make the arguements for subcommand 'cache' required.
13− let arg_group_required = !Path::new("cache").exists();
14−
15− ClapApp::new(crate_name!())
11+ let app = ClapApp::new(crate_name!())
1612 .version(crate_version!())
1713 .global_setting(clap_color_setting)
1814 .global_setting(AppSettings::DeriveDisplayOrder)
@@ -380,7 +376,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
380376 .hidden(true)
381377 .help("Show bat's cache directory."),
382378 )
383− .subcommand(
379+ .help_message("Print this help message.")
380+ .version_message("Show version information.");
381+
382+ // Check if the current directory contains a file name cache. Otherwise,
383+ // enable the 'bat cache' subcommand.
384+ if Path::new("cache").exists() {
385+ app
386+ } else {
387+ app.subcommand(
384388 SubCommand::with_name("cache")
385389 .about("Modify the syntax-definition and theme cache")
386390 .arg(
@@ -402,7 +406,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
402406 .group(
403407 ArgGroup::with_name("cache-actions")
404408 .args(&["build", "clear"])
405− .required(arg_group_required),
409+ .required(true),
406410 )
407411 .arg(
408412 Arg::with_name("source")
@@ -422,11 +426,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
422426 "Use a different directory to store the cached syntax and theme set.",
423427 ),
424428 )
425− .arg(Arg::with_name("blank").long("blank").requires("build").help(
426− "Create completely new syntax and theme sets \
427− (instead of appending to the default sets).",
428− )),
429+ .arg(
430+ Arg::with_name("blank")
431+ .long("blank")
432+ .requires("build")
433+ .help(
434+ "Create completely new syntax and theme sets \
435+ (instead of appending to the default sets).",
436+ ),
437+ ),
429438 )
430− .help_message("Print this help message.")
431− .version_message("Show version information.")
439+ }
432440}