highlight 0.1.0.0 → 1.0.0.0
raw patch · 2 files changed
+78/−22 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +77/−21
- highlight.cabal +1/−1
README.md view
@@ -8,45 +8,101 @@ [](http://stackage.org/nightly/package/highlight)  -`highlight` is a +`highlight` is a command line program for highlighting parts of a file matching+a regex. -For example, imagine the following Haskell data types and values:+For example, take a look at the following file: -```haskell-data Foo = Foo { foo1 :: Integer , foo2 :: [String] } deriving Show+ -foo :: Foo-foo = Foo 3 ["hello", "goodbye"]+`highlight` can be used to highlight the regex `cat`: -data Bar = Bar { bar1 :: Double , bar2 :: [Foo] } deriving Show+ -bar :: Bar-bar = Bar 10.55 [foo, foo]-```+## Uses -If you run this in `ghci` and type `print bar`, you'll get output like this:+This package installs two binaries, `highlight` and `hrep`. The following+section explains the main uses of `highlight` and `hrep`. -```haskell-> print bar-Bar {bar1 = 10.55, bar2 = [Foo {foo1 = 3, foo2 = ["hello","goodbye"]},Foo {foo1 = 3, foo2 = ["hello","goodbye"]}]}+### `highlight`++`highlight` is used to highlight a given regex in a file, while printing out+all lines of the file.++The short example above show how to use `highlight` to highlight a regex in a+single file. It is also possible to use `highlight` on multiple files at once:++++`highlight` will color and stripe the filenames to make it easier to see which+line came from which file. This also shows an example of the `--ignore-case`+option, which is similar to `grep`'s `--ignore-case` option.++### highlight output from `grep`++`highlight` has a special option for highlighting output from `grep`:++++This `--from-grep` option will color and stripe filenames, similar to the+previous example.++### `hrep`++With the previous `--from-grep` option to `highlight`, one unfortunate point is+that the regex has to be specified twice, once to `grep` and once to+`highlight`.++The `hrep` command can solve this for us. It is just like the `grep` command,+but it will color and stripe filenames:++++## Installation++`highlight` and `hrep` can be installed with+[`stack`](https://docs.haskellstack.org/en/stable/README/):++```sh+$ stack install highlight ``` -This is pretty hard to read. Imagine if there were more fields or it were even-more deeply nested. It would be even more difficult to read.+It should also be possible to use `cabal` to install this package. -`pretty-simple` can be used to print `bar` in an easy-to-read format:+## Other ways to highlight parts of files -+It is possible to highlight lines matching a given regex with `grep` two+different ways. -## Usage+1. Use a special regex that will match any line, but only highlight the part+ desired. It would look like this: -## Features+ ```sh+ $ grep 'about|$' file-cats file-dogs file-goats+ ``` -## Why not `(some other package)`?+2. Give a large `--context` flag: + ```sh+ $ grep --context 9999 'about' file-cats file-dogs file-goats+ ```++However, neither of these will color and stripe filenames.+ ## Contributions Feel free to open an [issue](https://github.com/cdepillabout/pretty-simple/issues) or [PR](https://github.com/cdepillabout/pretty-simple/pulls) for any bugs/problems/suggestions/improvements.++### Additional flags++`highlight` and `hrep` do not currently support all flags and options that+`grep` does. Ideally, `highlight` and `hrep` would be drop-in replacements for+`grep`, supporting all the same flags and options as `grep`.++If there is a flag or option you frequently use and want supported with+`highlight` or `hrep`, please feel free to open an issue or PR. Some+flags/options will be relatively easy to support, while some may require quite+a large amount of additional code.
highlight.cabal view
@@ -1,5 +1,5 @@ name: highlight-version: 0.1.0.0+version: 1.0.0.0 synopsis: Command line tool for highlighting parts of files matching a regex. description: Please see <https://github.com/cdepillabout/highlight#readme README.md>. homepage: https://github.com/cdepillabout/highlight