diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml index 9dee85035..c893cad98 100644 --- a/.github/workflows/go-cross.yml +++ b/.github/workflows/go-cross.yml @@ -29,4 +29,4 @@ jobs: run: go test -v -cover ./... - name: Build - run: go build -v -ldflags "-s -w" -trimpath -o ./dist/lego ./cmd/lego/ + run: go build -v -ldflags "-s -w" -trimpath -o ./dist/lego ./ diff --git a/.goreleaser.yml b/.goreleaser.yml index c358f8a38..7b4fbf69e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -5,7 +5,7 @@ project_name: lego builds: - binary: lego - main: ./cmd/lego/ + main: . env: - CGO_ENABLED=0 flags: diff --git a/Makefile b/Makefile index 8536dfc40..245001aaf 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ export GO111MODULE=on export CGO_ENABLED=0 LEGO_IMAGE := goacme/lego -MAIN_DIRECTORY := ./cmd/lego/ +MAIN_DIRECTORY := . BIN_OUTPUT := $(if $(filter $(shell go env GOOS), windows), dist/lego.exe, dist/lego) @@ -69,7 +69,7 @@ generate-dns: go generate ./... validate-doc: generate-dns -validate-doc: DOC_DIRECTORIES := ./docs/ ./cmd/ +validate-doc: DOC_DIRECTORIES := ./docs/ ./zz_gen_version.go validate-doc: @if git diff --exit-code --quiet $(DOC_DIRECTORIES) 2>/dev/null; then \ echo 'All documentation changes are done the right way.'; \ diff --git a/cmd/cmd.go b/cmd/cmd.go index 6ccd1c355..6f6b1a80a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -2,6 +2,16 @@ package cmd import "github.com/urfave/cli/v3" +// CreateRootCommand Creates the root CLI command. +func CreateRootCommand() *cli.Command { + return &cli.Command{ + Name: "lego", + Usage: "ACME client written in Go", + EnableShellCompletion: true, + Commands: CreateCommands(), + } +} + // CreateCommands Creates all CLI commands. func CreateCommands() []*cli.Command { return []*cli.Command{ diff --git a/docs/content/installation/_index.md b/docs/content/installation/_index.md index a9cb68b93..ecf203af2 100644 --- a/docs/content/installation/_index.md +++ b/docs/content/installation/_index.md @@ -80,7 +80,7 @@ Requirements: To install the latest version from sources, just run: ```bash -go install github.com/go-acme/lego/v5/cmd/lego@latest +go install github.com/go-acme/lego/v5@latest ``` or diff --git a/e2e/loader/loader.go b/e2e/loader/loader.go index e5d7e6cb7..62ada13ab 100644 --- a/e2e/loader/loader.go +++ b/e2e/loader/loader.go @@ -255,9 +255,7 @@ func buildLego(ctx context.Context) (string, func(), error) { return "", func() {}, err } - mainFolder := filepath.Join(projectRoot, "cmd", "lego") - - err = os.Chdir(mainFolder) + err = os.Chdir(projectRoot) if err != nil { return "", func() {}, err } diff --git a/internal/clihelp/generator.go b/internal/clihelp/generator.go index e50ff083a..48fd10708 100644 --- a/internal/clihelp/generator.go +++ b/internal/clihelp/generator.go @@ -84,14 +84,14 @@ func generate(ctx context.Context) error { return nil } -// createStubApp Construct cli app, very similar to cmd/lego/main.go. +// createStubApp Construct cli app, very similar to main.go. // Notable differences: // - do not include version information, because we're likely running against a snapshot // - skip DNS help and provider list, as initialization takes time, and we don't generate `lego dns --help` here. func createStubApp() *cli.Command { return &cli.Command{ Name: "lego", - Usage: "Let's Encrypt client written in Go", + Usage: "ACME client written in Go", Commands: cmd.CreateCommands(), } } diff --git a/internal/releaser/generator.go b/internal/releaser/generator.go index f24aea25f..51b12afb3 100644 --- a/internal/releaser/generator.go +++ b/internal/releaser/generator.go @@ -22,7 +22,7 @@ const ( const ( versionTemplate = "templates/version.go.tmpl" - versionTargetFile = "./cmd/lego/zz_gen_version.go" + versionTargetFile = "./zz_gen_version.go" ) //go:embed templates diff --git a/internal/releaser/releaser.go b/internal/releaser/releaser.go index 57805cbe0..7fa6f448e 100644 --- a/internal/releaser/releaser.go +++ b/internal/releaser/releaser.go @@ -22,7 +22,7 @@ const ( modeMajor = "major" ) -const versionSourceFile = "./cmd/lego/zz_gen_version.go" +const versionSourceFile = "./zz_gen_version.go" const ( commentRelease = "release" diff --git a/cmd/lego/main.go b/main.go similarity index 69% rename from cmd/lego/main.go rename to main.go index 38d5d3a2c..116b8ba0b 100644 --- a/cmd/lego/main.go +++ b/main.go @@ -14,13 +14,8 @@ import ( ) func main() { - app := &cli.Command{ - Name: "lego", - Usage: "Let's Encrypt client written in Go", - Version: getVersion(), - EnableShellCompletion: true, - Commands: cmd.CreateCommands(), - } + app := cmd.CreateRootCommand() + app.Version = getVersion() cli.VersionPrinter = func(cmd *cli.Command) { fmt.Printf("lego version %s %s/%s\n", cmd.Version, runtime.GOOS, runtime.GOARCH) diff --git a/cmd/lego/zz_gen_version.go b/zz_gen_version.go similarity index 100% rename from cmd/lego/zz_gen_version.go rename to zz_gen_version.go