Skip to content

Commit

Permalink
moving to reggi name
Browse files Browse the repository at this point in the history
  • Loading branch information
byxorna committed Feb 24, 2021
1 parent 2354f6b commit 43fc8be
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 518 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ all: build
.PHONY: build

build:
@go build -o bin/regtest \
-ldflags "-X '$(pkg)/pkg/version.Commit=$(git_commit)' -X '$(pkg)/pkg/version.Date=$(date)' -X '$(pkg)/pkg/version.Version=$(git_tag)'" ./cmd/
@go build -o bin/reggi \
-ldflags "-X '$(pkg)/pkg/version.Commit=$(git_commit)' -X '$(pkg)/pkg/version.Date=$(date)' -X '$(pkg)/pkg/version.Version=$(git_tag)'" ./cmd/reggi

dev: build
@./bin/regtest pkg/ui/model.go test/fixtures/mac.log test/fixtures/test.txt
@./bin/reggi pkg/ui/model.go test/fixtures/mac.log test/fixtures/test.txt

29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Regtest
# Reggi

Interactively validate regex against test data in your console

Expand All @@ -8,6 +8,33 @@ Interactively validate regex against test data in your console

![Example 3](./assets/example3.png)

# Install

```
$ go get github.com/byxorna/reggi/cmd/reggi
```

Then, `reggi some.txt files.txt` to interactively test your regexp against your files.

# Use

## Input Mode

Enter a regex to match against the currently focused buffer. Matches are highlighted.

- `ctrl-y` enable match all expressions
- `ctrl-l` enable multiline match: ^ and $ match begin/end line
- `ctrl-s` enable span line: let . match \n
- `ctrl-i` enable insensitive matching
- Press `esc` to enter pager

## Pager Mode

- `i`,`a` to go back to the regex editor
- `H`,`L` to change buffers (if multiple files are open)
- Normal pagination (`hjkl`, `ctrl-f`, `ctrl-b`, `g`, `G`)
- `q`,`ctrl-c` to quit

# Dev

```
Expand Down
9 changes: 9 additions & 0 deletions cmd/reggi/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/byxorna/regtest/pkg/app"
)

func main() {
app.Execute()
}
25 changes: 0 additions & 25 deletions cmd/regtest.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ require (
github.com/mattn/go-runewidth v0.0.10
github.com/muesli/termenv v0.7.4
github.com/rivo/tview v0.0.0-20210117162420-745e4ceeb711
github.com/spf13/cobra v1.1.1 // indirect
github.com/spf13/cobra v1.1.3 // indirect
)
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/cobra v1.1.3 h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
Expand Down Expand Up @@ -370,6 +372,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
35 changes: 35 additions & 0 deletions pkg/app/reggi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package app

import (
"fmt"
"os"

"github.com/byxorna/regtest/pkg/ui"
"github.com/byxorna/regtest/pkg/version"
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: version.Name,
Short: "Reggi is an interactive regular expression tester",
Version: version.Version,
RunE: func(cmd *cobra.Command, args []string) error {
model, err := ui.New(args)
if err != nil {
return fmt.Errorf("unable to initialize model: %v", err)
}
p := tea.NewProgram(*model)
p.EnterAltScreen()
err = p.Start()
p.ExitAltScreen()
return err
},
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
147 changes: 0 additions & 147 deletions pkg/cli/cli.go

This file was deleted.

55 changes: 0 additions & 55 deletions pkg/cli/fileview.go

This file was deleted.

Loading

0 comments on commit 43fc8be

Please sign in to comment.