Skip to content

Commit

Permalink
Move config-dir and cache-dir from 'bat cache' to 'bat'
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Feb 7, 2019
1 parent cff01d8 commit e09499b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ and theme. To add new syntax definitions, do the following.
Create a folder with syntax definition files:

```bash
mkdir -p "$(bat cache --config-dir)/syntaxes"
cd "$(bat cache --config-dir)/syntaxes"
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
Expand All @@ -298,8 +298,8 @@ This works very similar to how we add new syntax definitions.

First, create a folder with the new syntax highlighting themes:
```bash
mkdir -p "$(bat cache --config-dir)/themes"
cd "$(bat cache --config-dir)/themes"
mkdir -p "$(bat --config-dir)/themes"
cd "$(bat --config-dir)/themes"
# Download a theme in '.tmTheme' format, for example:
git clone https://github.com/greggb/sublime-snazzy
Expand Down
8 changes: 4 additions & 4 deletions doc/README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
構文定義ファイルを入れておくためのフォルダを作る:

```bash
mkdir -p "$(bat cache --config-dir)/syntaxes"
cd "$(bat cache --config-dir)/syntaxes"
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
Expand All @@ -290,8 +290,8 @@ bat cache --clear

まず、新しいシンタックスハイライトのテーマのフォルダを作ります:
```bash
mkdir -p "$(bat cache --config-dir)/themes"
cd "$(bat cache --config-dir)/themes"
mkdir -p "$(bat --config-dir)/themes"
cd "$(bat --config-dir)/themes"
# Download a theme in '.tmTheme' format, for example:
git clone https://github.com/greggb/sublime-snazzy
Expand Down
25 changes: 13 additions & 12 deletions src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.hidden(true)
.help("Show path to the configuration file."),
)
.arg(
Arg::with_name("config-dir")
.long("config-dir")
.hidden(true)
.help("Show bat's configuration directory."),
)
.arg(
Arg::with_name("cache-dir")
.long("cache-dir")
.hidden(true)
.help("Show bat's cache directory."),
)
.subcommand(
SubCommand::with_name("cache")
.about("Modify the syntax-definition and theme cache")
Expand All @@ -368,20 +380,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.short("c")
.help("Remove the cached syntax definitions and themes."),
)
.arg(
Arg::with_name("config-dir")
.long("config-dir")
.short("d")
.help("Show bat's configuration directory."),
)
.arg(
Arg::with_name("cache-dir")
.long("cache-dir")
.help("Show bat's cache directory."),
)
.group(
ArgGroup::with_name("cache-actions")
.args(&["build", "clear", "config-dir", "cache-dir"])
.args(&["build", "clear"])
.required(arg_group_required),
)
.arg(
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
assets.save(target_dir)?;
} else if matches.is_present("clear") {
clear_assets();
} else if matches.is_present("config-dir") {
writeln!(io::stdout(), "{}", config_dir())?;
} else if matches.is_present("cache-dir") {
writeln!(io::stdout(), "{}", cache_dir())?;
}

Ok(())
Expand Down Expand Up @@ -234,6 +230,12 @@ fn run() -> Result<bool> {
} else if app.matches.is_present("config-file") {
println!("{}", config_file().to_string_lossy());

Ok(true)
} else if app.matches.is_present("config-dir") {
writeln!(io::stdout(), "{}", config_dir())?;
Ok(true)
} else if app.matches.is_present("cache-dir") {
writeln!(io::stdout(), "{}", cache_dir())?;
Ok(true)
} else {
run_controller(&config)
Expand Down

0 comments on commit e09499b

Please sign in to comment.