diff options
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/hexai-lsp/main_test.go | 31 | ||||
| -rw-r--r-- | cmd/hexai-tmux-action/main.go | 41 | ||||
| -rw-r--r-- | cmd/hexai/main_test.go | 32 |
3 files changed, 51 insertions, 53 deletions
diff --git a/cmd/hexai-lsp/main_test.go b/cmd/hexai-lsp/main_test.go index 987bfb4..387b640 100644 --- a/cmd/hexai-lsp/main_test.go +++ b/cmd/hexai-lsp/main_test.go @@ -1,23 +1,22 @@ package main import ( - "bytes" - "log" - "os" - "testing" + "bytes" + "log" + "os" + "testing" ) func TestMain_Version(t *testing.T) { - oldArgs := os.Args - defer func() { os.Args = oldArgs }() - os.Args = []string{"hexai-lsp", "-version"} - var buf bytes.Buffer - old := log.Writer() - log.SetOutput(&buf) - defer log.SetOutput(old) - main() - if buf.Len() == 0 { - t.Fatalf("expected version log") - } + oldArgs := os.Args + defer func() { os.Args = oldArgs }() + os.Args = []string{"hexai-lsp", "-version"} + var buf bytes.Buffer + old := log.Writer() + log.SetOutput(&buf) + defer log.SetOutput(old) + main() + if buf.Len() == 0 { + t.Fatalf("expected version log") + } } - diff --git a/cmd/hexai-tmux-action/main.go b/cmd/hexai-tmux-action/main.go index 02cfe09..2d8793b 100644 --- a/cmd/hexai-tmux-action/main.go +++ b/cmd/hexai-tmux-action/main.go @@ -1,30 +1,29 @@ package main import ( - "context" - "flag" - "fmt" - "os" + "context" + "flag" + "fmt" + "os" - "codeberg.org/snonux/hexai/internal/hexaiaction" + "codeberg.org/snonux/hexai/internal/hexaiaction" ) func main() { - infile := flag.String("infile", "", "Read input from this file instead of stdin") - outfile := flag.String("outfile", "", "Write output to this file instead of stdout") - uiChild := flag.Bool("ui-child", false, "INTERNAL: run interactive UI and write to -outfile atomically") - tmuxTarget := flag.String("tmux-target", "", "tmux split target (advanced)") - tmuxSplit := flag.String("tmux-split", "v", "tmux split orientation: v or h") - tmuxPercent := flag.Int("tmux-percent", 33, "tmux split size percentage (1-100)") - flag.Parse() + infile := flag.String("infile", "", "Read input from this file instead of stdin") + outfile := flag.String("outfile", "", "Write output to this file instead of stdout") + uiChild := flag.Bool("ui-child", false, "INTERNAL: run interactive UI and write to -outfile atomically") + tmuxTarget := flag.String("tmux-target", "", "tmux split target (advanced)") + tmuxSplit := flag.String("tmux-split", "v", "tmux split orientation: v or h") + tmuxPercent := flag.Int("tmux-percent", 33, "tmux split size percentage (1-100)") + flag.Parse() - opts := hexaiaction.Options{ - Infile: *infile, Outfile: *outfile, - UIChild: *uiChild, TmuxTarget: *tmuxTarget, TmuxSplit: *tmuxSplit, TmuxPercent: *tmuxPercent, - } - if err := hexaiaction.RunCommand(context.Background(), opts, os.Stdin, os.Stdout, os.Stderr); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } + opts := hexaiaction.Options{ + Infile: *infile, Outfile: *outfile, + UIChild: *uiChild, TmuxTarget: *tmuxTarget, TmuxSplit: *tmuxSplit, TmuxPercent: *tmuxPercent, + } + if err := hexaiaction.RunCommand(context.Background(), opts, os.Stdin, os.Stdout, os.Stderr); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } - diff --git a/cmd/hexai/main_test.go b/cmd/hexai/main_test.go index beb684b..70c844f 100644 --- a/cmd/hexai/main_test.go +++ b/cmd/hexai/main_test.go @@ -1,23 +1,23 @@ package main import ( - "io" - "os" - "testing" + "io" + "os" + "testing" ) func TestMain_Version(t *testing.T) { - oldArgs := os.Args - defer func() { os.Args = oldArgs }() - os.Args = []string{"hexai", "-version"} - r, w, _ := os.Pipe() - old := os.Stdout - os.Stdout = w - defer func() { os.Stdout = old }() - main() - w.Close() - b, _ := io.ReadAll(r) - if len(b) == 0 { - t.Fatalf("expected version output") - } + oldArgs := os.Args + defer func() { os.Args = oldArgs }() + os.Args = []string{"hexai", "-version"} + r, w, _ := os.Pipe() + old := os.Stdout + os.Stdout = w + defer func() { os.Stdout = old }() + main() + w.Close() + b, _ := io.ReadAll(r) + if len(b) == 0 { + t.Fatalf("expected version output") + } } |
