Skip to content

Commit a5bfe3b

Browse files
committed
refactor: reorganize into idiomatic Go project layout
Move from flat package main to structured layout: - cmd/: all cobra commands and CLI logic (package cmd) - internal/color/: ANSI color utilities - internal/fuzzy/: fuzzy matching for interactive selectors - main.go: slim entry point calling cmd.Execute() Update goreleaser ldflags to use cmd.Version.
1 parent 5be4d4e commit a5bfe3b

45 files changed

Lines changed: 345 additions & 328 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ builds:
1313
- main: .
1414
binary: wt
1515
ldflags:
16-
- -s -w -X main.version={{.Version}}
16+
- -s -w -X github.com/timvw/wt/cmd.Version={{.Version}}
1717
env:
1818
- CGO_ENABLED=0
1919
goos:

checkout.go renamed to cmd/checkout.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"
@@ -7,6 +7,7 @@ import (
77

88
"github.com/manifoldco/promptui"
99
"github.com/spf13/cobra"
10+
"github.com/timvw/wt/internal/fuzzy"
1011
)
1112

1213
var checkoutCmd = &cobra.Command{
@@ -33,7 +34,7 @@ var checkoutCmd = &cobra.Command{
3334
prompt := promptui.Select{
3435
Label: "Select branch to checkout",
3536
Items: branches,
36-
Searcher: fuzzySearcher(branches),
37+
Searcher: fuzzy.Searcher(branches),
3738
StartInSearchMode: true,
3839
}
3940
_, result, err := prompt.Run()

cleanup.go renamed to cmd/cleanup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"

cleanup_test.go renamed to cmd/cleanup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"os"

config.go renamed to cmd/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"

config_cmd.go renamed to cmd/config_cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"

config_test.go renamed to cmd/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"bytes"

create.go renamed to cmd/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"

default.go renamed to cmd/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"fmt"

default_test.go renamed to cmd/default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package cmd
22

33
import (
44
"strings"

0 commit comments

Comments
 (0)