~yerinalexey/rex

ca1f03db58e806383e2218ec9f0a3b50ea956226 — Alexey Yerin 5 months ago 3e32b66
Reverse -no-print

It should be opt-in instead of opt-out.
2 files changed, 6 insertions(+), 6 deletions(-)

M README.md
M main.go
M README.md => README.md +2 -2
@@ 31,7 31,7 @@ of test data highlighted accordingly to them matching a regex.

You can switch between them using `Tab` or `Shift+Tab`. `Escape` exits
the application and prints input regex to standard output unless
`-no-print` flag is specified.
`-print-regex=0` flag is specified.

List can be scrolled using Vi keys: `j` - down, `k` - up. Input field
supports readline-like bindings: [reference][inputfield].


@@ 40,7 40,7 @@ supports readline-like bindings: [reference][inputfield].

Flags/options reference:
- `-input REGEX` - set default value for regex field (`.` if not set)
- `-no-print` - do not print regex after exit (`false` if not set)
- `-print-regex` - print regex after exit (`true` by default)
- `-version` - print version number
- `-help` - show help message


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

	// Do not print regex after exit
	noPrint bool
	// Print regex after exit
	printRegex bool
}

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


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

	// TODO: More flags
	flag.StringVar(&opts.input, "input", ".", "Default value for regex input")
	flag.BoolVar(&opts.noPrint, "no-print", false, "Do not print regex after exit")
	flag.BoolVar(&opts.printRegex, "print-regex", true, "Print regex after exit")
	flag.BoolVar(&opts.version, "version", false, "Show version number")
	flag.BoolVar(&opts.help, "help", false, "Show this message")
	flag.Parse()


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

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