~yerinalexey/rex

fb6f34b135997319032bbb2d2fa693e1675dda34 — Alexey Yerin 4 months ago de8c92b
Rename --print-regex to just --print
2 files changed, 7 insertions(+), 7 deletions(-)

M README.md
M main.go
M README.md => README.md +3 -3
@@ 43,7 43,7 @@ The interface consists of an input field with a regular expression to use, and
the file colored depending on what lines match that regular expression.

Those can be switched between using `Tab` or `Shift+Tab`. `Escape` exits the
application and prints the input to standard output unless `--print-regex=0` is
application and prints the input to standard output unless `--print=0` is
specified.

File matches can be scrolled using Vi keys: `j` - down, `k` - up, etc. Input


@@ 53,13 53,13 @@ field supports readline-like bindings: [reference].

The following options are supported:
- `--input REGEX` (`-i REGEX`) - default value for the input field (default: `.`)
- `--print-regex` (`-p`) - print the input after exit (default: `true`)
- `--print` (`-p`) - print the input after exit (default: `true`)
- `--version` (`-V`) - show version number
- `--help` (`-h`) - show the help message

To turn off boolean flags, they can be assigned to `0`
(or other falsy value, see below) with an equal sign: sign: `-p=0` or
`--print-regex=false`.
`--print=false`.

The following values can be accepted by boolean flags: `1`, `0`, `t`, `f`,
`true`, `false`, `TRUE`, `FALSE`, `True`, `False`.

M main.go => main.go +4 -4
@@ 45,8 45,8 @@ type Options struct {
	// Default value for regex input
	input string

	// Print regex after exit
	printRegex bool
	// Print the input field contents after exit
	printOnExit bool
}

func fatalf(format string, v ...interface{}) {


@@ 126,7 126,7 @@ func main() {

	// TODO: More flags
	pflag.StringVarP(&opts.input, "input", "i", ".", "Default value for the input field")
	pflag.BoolVarP(&opts.printRegex, "print-regex", "p", true, "Print the input after exit")
	pflag.BoolVarP(&opts.printOnExit, "print", "p", true, "Print the input after exit")
	pflag.BoolVarP(&opts.version, "version", "V", false, "Show version number")
	pflag.BoolVarP(&opts.help, "help", "h", false, "Show this message")
	pflag.Parse()


@@ 203,7 203,7 @@ func main() {
		case tcell.KeyEscape:
			app.Stop()

			if opts.printRegex {
			if opts.printOnExit {
				fmt.Println(regexInput.GetText())
			}
		case tcell.KeyTab: