From ec89559cca7d5bb19bcb79bafe02e2f2acbe1ac6 Mon Sep 17 00:00:00 2001 From: zhenghaoz Date: Fri, 23 Oct 2026 22:13:33 +0800 Subject: [PATCH] refactor: move CLI sources to repository root --- .github/workflows/ci.yml | 2 +- .goreleaser.yaml | 8 ++++---- README.md | 4 ++-- cmd/gorse-cli/context.go => context.go | 0 cmd/gorse-cli/format.go => format.go | 0 cmd/gorse-cli/main.go => main.go | 3 +-- cmd/gorse-cli/main_test.go => main_test.go | 0 cmd/gorse-cli/table.go => table.go | 0 internal/version/version.go => version.go | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) rename cmd/gorse-cli/context.go => context.go (100%) rename cmd/gorse-cli/format.go => format.go (100%) rename cmd/gorse-cli/main.go => main.go (99%) rename cmd/gorse-cli/main_test.go => main_test.go (100%) rename cmd/gorse-cli/table.go => table.go (100%) rename internal/version/version.go => version.go (97%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d93e2e5..607073b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,5 +15,5 @@ jobs: go-version-file: go.mod - run: go test ./... - run: go vet ./... - - run: go build -o gorse-cli ./cmd/gorse-cli + - run: go build -o gorse-cli . - run: sh -n install.sh diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 2e85a68..448ed4b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -2,7 +2,7 @@ version: 2 project_name: gorse-cli builds: - id: gorse-cli - main: ./cmd/gorse-cli + main: . binary: gorse-cli env: - CGO_ENABLED=0 @@ -16,9 +16,9 @@ builds: - darwin_arm64 ldflags: - >- - -X 'github.com/gorse-io/cli/internal/version.Version={{ .Version }}' - -X 'github.com/gorse-io/cli/internal/version.GitCommit={{ .Commit }}' - -X 'github.com/gorse-io/cli/internal/version.BuildTime={{ .Date }}' + -X 'main.Version={{ .Version }}' + -X 'main.GitCommit={{ .Commit }}' + -X 'main.BuildTime={{ .Date }}' archives: - id: gorse-cli formats: [binary] diff --git a/README.md b/README.md index b885142..00977e6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Build from source: ```sh git clone https://github.com/gorse-io/cli.git cd cli -go build -o gorse-cli ./cmd/gorse-cli +go build -o gorse-cli . ``` Use a source checkout rather than `go install ...@latest`: this module includes @@ -44,7 +44,7 @@ Contexts and API keys remain in the system keyring under the existing ```sh go test ./... go vet ./... -go build -o gorse-cli ./cmd/gorse-cli +go build -o gorse-cli . ``` Tests start a real local Gorse Master with temporary SQLite stores. The Gorse diff --git a/cmd/gorse-cli/context.go b/context.go similarity index 100% rename from cmd/gorse-cli/context.go rename to context.go diff --git a/cmd/gorse-cli/format.go b/format.go similarity index 100% rename from cmd/gorse-cli/format.go rename to format.go diff --git a/cmd/gorse-cli/main.go b/main.go similarity index 99% rename from cmd/gorse-cli/main.go rename to main.go index 19c9af1..2caa4b1 100644 --- a/cmd/gorse-cli/main.go +++ b/main.go @@ -24,7 +24,6 @@ import ( "strings" jsonpatch "github.com/evanphx/json-patch/v5" - "github.com/gorse-io/cli/internal/version" gorse "github.com/gorse-io/gorse-go" adminclient "github.com/gorse-io/gorse/client" "github.com/samber/lo" @@ -38,7 +37,7 @@ var rootCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Show version if showVersion, _ := cmd.PersistentFlags().GetBool("version"); showVersion { - cmd.Println(version.BuildInfo()) + cmd.Println(BuildInfo()) return } _ = cmd.Help() diff --git a/cmd/gorse-cli/main_test.go b/main_test.go similarity index 100% rename from cmd/gorse-cli/main_test.go rename to main_test.go diff --git a/cmd/gorse-cli/table.go b/table.go similarity index 100% rename from cmd/gorse-cli/table.go rename to table.go diff --git a/internal/version/version.go b/version.go similarity index 97% rename from internal/version/version.go rename to version.go index e937855..c6af501 100644 --- a/internal/version/version.go +++ b/version.go @@ -1,4 +1,4 @@ -package version +package main import ( "fmt"