forked from tordarus/format
		
	show version
This commit is contained in:
		
							
								
								
									
										6
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								go.mod
									
									
									
									
									
								
							@ -3,7 +3,11 @@ module git.milar.in/milarin/format
 | 
			
		||||
go 1.18
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/fatih/color v1.13.0 // indirect
 | 
			
		||||
	git.milar.in/milarin/buildinfo v1.0.0
 | 
			
		||||
	github.com/fatih/color v1.13.0
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
require (
 | 
			
		||||
	github.com/mattn/go-colorable v0.1.12 // indirect
 | 
			
		||||
	github.com/mattn/go-isatty v0.0.14 // indirect
 | 
			
		||||
	golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							@ -1,3 +1,5 @@
 | 
			
		||||
git.milar.in/milarin/buildinfo v1.0.0 h1:tw98GupUYl/0a/3aPGuezhE4wseycOSsbcLp70hy60U=
 | 
			
		||||
git.milar.in/milarin/buildinfo v1.0.0/go.mod h1:arI9ZoENOgcZcanv25k9y4dKDUhPp0buJrlVerGruas=
 | 
			
		||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
 | 
			
		||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
 | 
			
		||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.go
									
									
									
									
									
								
							@ -10,6 +10,8 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"unicode/utf8"
 | 
			
		||||
 | 
			
		||||
	"git.milar.in/milarin/buildinfo"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@ -45,6 +47,8 @@ var (
 | 
			
		||||
	// it may be useful to have a boolean flag for this behavior
 | 
			
		||||
	lineParseAmount = flag.Int("n", 1, "amount of lines to feed into input pattern")
 | 
			
		||||
 | 
			
		||||
	showVersion = flag.Bool("v", false, "show version and exit")
 | 
			
		||||
 | 
			
		||||
	replacePattern     = regexp.MustCompile(`\{(\d+)(?::(.*?))?(?::(.*?))?(?::(.*?))?\}`)
 | 
			
		||||
	numMutationPattern = regexp.MustCompile(`([+\-*/])(\d+|\((\d+)\))`)
 | 
			
		||||
)
 | 
			
		||||
@ -52,6 +56,11 @@ var (
 | 
			
		||||
func main() {
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
 | 
			
		||||
	if *showVersion {
 | 
			
		||||
		buildinfo.Print(buildinfo.Options{})
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pattern, err := regexp.Compile(*input)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user