Commit Graph

409 Commits

Author SHA1 Message Date
Pit Kleyersburg
747d074be1 Replace Cow by String 2018-05-10 12:20:38 +02:00
Pit Kleyersburg
61109ece15 Create OutputComponents struct, use HashSet 2018-05-10 12:20:38 +02:00
Pit Kleyersburg
389edd7239 Combine OutputComponents and PredefinedStyles
This commit tries to simply the change. Instead of separating an
`OutputComponent` and a `PredefinedStyle`, I have combined the two into
just `OutputComponent`.

To still have the styles work, I added an impl to `OutputComponent` with
a function `components` which returns the components related to the
specified component.

For a simple output component this is trivial, but for the predefined
styles this is a list of other components.

The evaluating of the command-line parameter simplified significantly,
making use of Claps `values_t!` macro to parse the supplied parameters
into a `Vec<OutputComponent>`. After that it is simply a task of
combining all supplied output components into one vector.

Important: this means that the styles are now additive, rather than one
of the predefined styles overruling other parameters supplied.
2018-05-10 12:20:38 +02:00
Pit Kleyersburg
23813cc08b Make --style parameter more flexible
The `--style` parameter now accepts a comma-separated list of strings,
where every element defines either a single output component (`changes`,
`grid`, `header`, `numbers`) or a predefined style (`full`,
`line-numbers`, `plain`).

If available, bat picks the first predefined style in the user-supplied
style-list and ignores everything else. If no predefined style was
requested, the other parameters that are simple output components will
be used.

Examples:

    --style changes,full,numbers

  Will internally be reduced to only the predefined style `full`.

    --style plain,full

  Will internally be reduced to only the predefined style `plain`.

    --style changes,numbers

  Will not be reduced, because the list does not contain any predefined
  styles.

(Note: if `grid` is requested but no other parameters, bat still creates
the left-most column with a width of `PANEL_WIDTH`. I didn't want to
introduce further logic in this PR that drops or adapts the width of the
left column.)
2018-05-10 12:20:38 +02:00
David Peter
fdeb98e859
Add usage examples 2018-05-09 00:33:49 +02:00
David Peter
6a417886aa
Add comment about paging & concatenation 2018-05-09 00:12:25 +02:00
sharkdp
8b9991d780 Append newline at the end of the file if necessary 2018-05-08 23:49:59 +02:00
sharkdp
f59ddd1e36 Update dependencies 2018-05-08 23:49:07 +02:00
sharkdp
f90b9d1acc Do not peek at FIFOs, closes #80 2018-05-08 23:23:41 +02:00
sharkdp
f7af537018 Filter out languages without extensions 2018-05-08 22:57:29 +02:00
sharkdp
fd68af8031 Paint file extensions in green 2018-05-08 22:57:29 +02:00
sharkdp
ebdef04c8f Compute 'longest' for non-hidden languages only 2018-05-08 22:57:29 +02:00
sharkdp
a4150600af Correctly update num_chars 2018-05-08 22:57:29 +02:00
Connor Kuehl
49223eed06 Remove term_width from Printer, its options owns it. 2018-05-08 22:57:29 +02:00
Connor Kuehl
7dc7133b3c Add revisions for line-wrapping and terminal width.
* Adds separator.length() to calculation for desired width.
* Replaces use of term_width with options.term_width.
* Adds the comma and space separator to calculation for line-wrapping.
2018-05-08 22:57:29 +02:00
Connor Kuehl
e5e47716b0 Add term_width to options struct, move getting term_width to run() 2018-05-08 22:57:29 +02:00
Connor Kuehl
b4f8cd3bae Filter out languages that are hidden. 2018-05-08 22:57:29 +02:00
Connor Kuehl
ee3a37f3fc WIP edit desired width. 2018-05-08 22:57:29 +02:00
Connor Kuehl
4c60ab12cc Add simple line-wrapping for file extensions. 2018-05-08 22:57:29 +02:00
Connor Kuehl
ac32dd17c9 Adds requested revisions.
* removes redundant `.takes_value(false)`.
* changes Arg name to "list-languages" to be consistent with long-form.
* replaces unnecessary match statement with is_present().
* replaces unnecessary match statement on iter and uses unwrap_or()
instead.
* replaces for-loop with a call to join().
2018-05-08 22:57:29 +02:00
Connor Kuehl
4e3c57cc7c Rename and add comment to the match block. 2018-05-08 22:57:29 +02:00
Connor Kuehl
438a9a99ed Size language name column width to the length of the longest language. 2018-05-08 22:57:29 +02:00
Connor Kuehl
9b0877102c Display language and extensions from loaded assets. 2018-05-08 22:57:29 +02:00
Connor Kuehl
67bed73e15 Add --list-languages argument to clap. 2018-05-08 22:57:29 +02:00
sharkdp
ef7c39b159 Improve cache subcommand
* Remove the old `init-cache` subcommand

* Introduce a new `cache` subcommand that can be used like this:

    * `bat cache -h` - Show help
    * `bat cache --init` - Initialize cache from config dir
    * `bat cache --clear` - Reset the cache
    * `bat cache --config-dir` - Show config directory

* Update README

closes #44
2018-05-08 20:11:25 +02:00
sharkdp
8a399c8d7d Disable paging-mode if we read from an interactive TTY 2018-05-07 23:27:38 +02:00
sharkdp
9a0e444e09 Simplify stdout handling 2018-05-07 23:27:38 +02:00
sharkdp
438f3df345 Paint STDOUT bold, unify writeln statement 2018-05-07 23:27:38 +02:00
sharkdp
7e2e0c82ac Add support for reading from stdin, closes #2 2018-05-07 23:27:38 +02:00
sharkdp
da92154163 Re-format README 2018-05-07 20:06:01 +02:00
sharkdp
179bd4f525 Mention cmake in build instructions, closes #57 2018-05-07 20:03:56 +02:00
Ezinwa Okpoechi
53d67e2b6e Add printer
This adds a separate struct that handles printing of the different
tokens.
2018-05-07 08:57:21 +02:00
sharkdp
b625d07c34 Use syntect newlines mode (instead of nonewlines) 2018-05-06 19:50:48 +02:00
Ezinwa Okpoechi
ec606e5dcc Add option to disable automatic paging 2018-05-06 19:50:05 +02:00
Ezinwa Okpoechi
c253821a5e Open pager once for multiple files 2018-05-06 19:50:05 +02:00
sharkdp
ccb1d78b22 Remove short versions for --style and --color for now 2018-05-06 18:23:43 +02:00
sharkdp
9eb64b97fe Discover syntaxes by name and extention 2018-05-06 18:20:35 +02:00
sharkdp
15f0268bdc Use 'plain' style for non-interactive terminals 2018-05-06 16:15:22 +02:00
sharkdp
3fa70deaa7 Run 'cargo fmt' and enforce via Travis 2018-05-06 15:10:46 +02:00
Ezinwa Okpoechi
d4553c6b38 Add color flag
Colors are disabled if the terminal is not interactive unless explicitly
set otherwise
2018-05-06 14:47:53 +02:00
sharkdp
23d92d7641 Add TOML sublime syntax, closes #37 2018-05-06 14:34:10 +02:00
sharkdp
92729430fc Add elixir sublime syntax 2018-05-06 14:26:58 +02:00
sharkdp
3eb79d63ce Compute pathspec from absolute.strip_prefix(workdir) 2018-05-06 11:22:48 +02:00
Nakul Chaudhari
0483407775 Remove user specific change 2018-05-06 11:22:48 +02:00
Nakul Chaudhari
cbdf5c50c4 Fix bug where git modification markers would not be shown if directory
was not cwd

Git ignore Idea dir

Fix #22
2018-05-06 11:22:48 +02:00
Ezinwa Okpoechi
418b3c5ea1 Add less pager 2018-05-05 09:01:30 +02:00
Nakul Chaudhari
9dca3126b3 Hide everything but content for plain option style
fix #5
2018-05-03 22:49:37 +02:00
nakulcg
7df9a5fe82 Add --style option to disable line numbers and git markers (#43)
closes #5
2018-05-03 20:34:23 +02:00
Ezinwa Okpoechi
4bba08062c Add option to specify language 2018-05-03 17:00:35 +02:00
sharkdp
4e8ea815af Bump version 2018-05-03 09:07:58 +02:00