fix: tighten task 1 cli skeleton
This commit is contained in:
parent
46fab31436
commit
518b2c64d9
3 changed files with 16 additions and 4 deletions
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp(nil, nil, nil, nil)
|
app := cli.NewApp()
|
||||||
if err := app.Run(os.Args[1:]); err != nil {
|
if err := app.Run(os.Args[1:]); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import "fmt"
|
||||||
|
|
||||||
type App struct{}
|
type App struct{}
|
||||||
|
|
||||||
func NewApp(_, _, _, _ any) *App {
|
func NewApp() *App {
|
||||||
return &App{}
|
return &App{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
||||||
app := NewApp(nil, nil, nil, nil)
|
app := NewApp()
|
||||||
|
|
||||||
err := app.Run([]string{"unknown"})
|
err := app.Run([]string{"unknown"})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -15,7 +15,7 @@ func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
||||||
app := NewApp(nil, nil, nil, nil)
|
app := NewApp()
|
||||||
|
|
||||||
err := app.Run(nil)
|
err := app.Run(nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -25,3 +25,15 @@ func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
||||||
t.Fatalf("expected usage text in error, got %q", err.Error())
|
t.Fatalf("expected usage text in error, got %q", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAppRunAcceptsSetupAndMcp(t *testing.T) {
|
||||||
|
app := NewApp()
|
||||||
|
|
||||||
|
for _, command := range []string{"setup", "mcp"} {
|
||||||
|
t.Run(command, func(t *testing.T) {
|
||||||
|
if err := app.Run([]string{command}); err != nil {
|
||||||
|
t.Fatalf("expected %q to be accepted, got error: %v", command, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue