Skip to content

Commit

Permalink
Some goreleaser improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gschier committed Sep 5, 2024
1 parent 2723f5c commit bd8e535
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ version: 2

builds:
- binary: yaakcli
main: ./cmd/yaakcli/main.go
env:
- CGO_ENABLED=0
4 changes: 3 additions & 1 deletion cmd/yaakcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/yaakapp/yaakcli"
)

var version = "dev"

func main() {
yaakcli.Execute()
yaakcli.Execute(version)
}
35 changes: 22 additions & 13 deletions cmd_root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,31 @@ import (
"os"
)

var rootCmd = &cobra.Command{
Use: "plaak",
Short: "Develop plugins for Yaak",
Long: `Generate, build, and debug plugins for Yaak, the most intuitive desktop API client`,
Run: func(cmd *cobra.Command, args []string) {
println("Hello from Plaak")
},
}
func rootCmd(version string) *cobra.Command {
var fVersion bool
cmd := &cobra.Command{
Use: "plaak",
Short: "Develop plugins for Yaak",
Long: `Generate, build, and debug plugins for Yaak, the most intuitive desktop API client`,
Run: func(cmd *cobra.Command, args []string) {
if fVersion {
println(version)
os.Exit(0)
}

checkErr(cmd.Help())
},
}
cmd.AddCommand(buildCmd)
cmd.AddCommand(generateCmd)

cmd.Flags().BoolVar(&fVersion, "version", false, "Source directory to read from")

func init() {
rootCmd.AddCommand(buildCmd)
rootCmd.AddCommand(generateCmd)
return cmd
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
func Execute(version string) {
if err := rootCmd(version).Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
Expand Down

0 comments on commit bd8e535

Please sign in to comment.