~yerinalexey/rex

31c0a0cf37cbea874aa09d4b8db1f6060e0df636 — Alexey Yerin 5 months ago 8e5d320 1.0.0
Add version
3 files changed, 22 insertions(+), 0 deletions(-)

M README.md
A contrib/_incr_version
M main.go
M README.md => README.md +1 -0
@@ 39,6 39,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)
- `-version` - print version number
- `-help` - show help message

[Command line flag syntax](https://godocs.io/flag#hdr-Command_line_flag_syntax)

A contrib/_incr_version => contrib/_incr_version +8 -0
@@ 0,0 1,8 @@
#!/bin/sh

[ -n "$(git status -s)" ] && printf 'No\n' && exit 1

sed -i "s|VERSION = \"$1\"|VERSION = \"$2\"|" main.go

git add main.go
git commit -m"Bump version to $2"

M main.go => main.go +13 -0
@@ 30,10 30,17 @@ import (
	"github.com/rivo/tview"
)

const (
	VERSION = "1.0.0"
)

type Options struct {
	// Show help message
	help bool

	// Show version number
	version bool

	// Default value for regex input
	input string



@@ 114,6 121,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.version, "version", false, "Show version number")
	flag.BoolVar(&opts.help, "help", false, "Show this message")
	flag.Parse()



@@ 122,6 130,11 @@ func main() {
		return
	}

	if opts.version {
		fmt.Printf("rex %s\n", VERSION)
		return
	}

	file := flag.Arg(0)

	var data string