chore: initialize go cli skeleton
This commit is contained in:
parent
59b6cb2f18
commit
46fab31436
4 changed files with 68 additions and 0 deletions
16
cmd/email-mcp/main.go
Normal file
16
cmd/email-mcp/main.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"email-mcp/internal/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp(nil, nil, nil, nil)
|
||||
if err := app.Run(os.Args[1:]); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
3
go.mod
Normal file
3
go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module email-mcp
|
||||
|
||||
go 1.25.0
|
||||
22
internal/cli/app.go
Normal file
22
internal/cli/app.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package cli
|
||||
|
||||
import "fmt"
|
||||
|
||||
type App struct{}
|
||||
|
||||
func NewApp(_, _, _, _ any) *App {
|
||||
return &App{}
|
||||
}
|
||||
|
||||
func (a *App) Run(args []string) error {
|
||||
if len(args) == 0 {
|
||||
return fmt.Errorf("usage: email-mcp <setup|mcp>")
|
||||
}
|
||||
|
||||
switch args[0] {
|
||||
case "setup", "mcp":
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown command: %s", args[0])
|
||||
}
|
||||
}
|
||||
27
internal/cli/app_test.go
Normal file
27
internal/cli/app_test.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAppRunRejectsUnknownCommand(t *testing.T) {
|
||||
app := NewApp(nil, nil, nil, nil)
|
||||
|
||||
err := app.Run([]string{"unknown"})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for unknown command")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppRunShowsUsageWhenNoArgsProvided(t *testing.T) {
|
||||
app := NewApp(nil, nil, nil, nil)
|
||||
|
||||
err := app.Run(nil)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for missing command")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "usage:") {
|
||||
t.Fatalf("expected usage text in error, got %q", err.Error())
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue