diff --git a/brew.go b/brew.go new file mode 100644 index 0000000..a2e9026 --- /dev/null +++ b/brew.go @@ -0,0 +1,5 @@ +//go:build brew + +package main + +var hideInstallCommands = true diff --git a/build/build.sh b/build/build.sh index ff97964..ab2cb44 100644 --- a/build/build.sh +++ b/build/build.sh @@ -47,8 +47,8 @@ export GOOS="${OS}" export GO111MODULE=on export GOFLAGS="${GOFLAGS:-} -mod=mod " -printf "# BUILD output: %s\ttarget: %s/%s\tversion: %s\n" \ - "${OUTPUT}" "${OS}" "${ARCH}" "${VERSION}" +printf "# BUILD output: %s\ttarget: %s/%s\tversion: %s\ttags: %s\n" \ + "${OUTPUT}" "${OS}" "${ARCH}" "${VERSION}" "${GOTAGS:- }" printf "# BUILD building for " @@ -79,11 +79,12 @@ if [ -n "${GIT_COMMIT:-}" ]; then always_ldflags="${always_ldflags} -X $(go list -m)/pkg/version.GitCommit=${GIT_COMMIT}" fi -export CGO_CFLAGS="-O2 -target arm64-apple-macos12" +export CGO_CFLAGS="-O2" export CGO_LDFLAGS="-O2" go build \ -gcflags="${gogcflags}" \ + -tags="${GOTAGS:-}" \ -asmflags="${goasmflags}" \ -ldflags="${always_ldflags} ${goldflags}" \ -o "${OUTPUT}" \ diff --git a/cmd.go b/cmd.go index f9871f9..13c762e 100644 --- a/cmd.go +++ b/cmd.go @@ -26,7 +26,6 @@ var ( commandGroups = []string{ gBasic, gAdvanced, - gInstallation, } ) @@ -55,8 +54,6 @@ func NewCommand() *cobra.Command { cmd.AddCommand( NewDaemonCommand(), NewVersionCommand(), - NewInstallCommand(), - NewUninstallCommand(), NewLimitCommand(), NewDisableCommand(), NewSetDisableChargingPreSleepCommand(), @@ -67,6 +64,19 @@ func NewCommand() *cobra.Command { NewSetControlMagSafeLEDCommand(), ) + // If building for non-brew, show install commands. + // If building for brew, hide install commands because brew will handle installation. + if !hideInstallCommands { + cmd.AddGroup(&cobra.Group{ + ID: gInstallation, + Title: gInstallation, + }) + cmd.AddCommand( + NewInstallCommand(), + NewUninstallCommand(), + ) + } + return cmd } diff --git a/nonbrew.go b/nonbrew.go new file mode 100644 index 0000000..887a65a --- /dev/null +++ b/nonbrew.go @@ -0,0 +1,5 @@ +//go:build !brew + +package main + +var hideInstallCommands = false