| 1 | // Copyright (c) Bartłomiej Płotka @bwplotka |
| 2 | // Licensed under the Apache License 2.0. |
| 3 | |
| 4 | //lint:file-ignore faillint main.go can use fmt.Print* family for error logging, when logger is not ready. |
| 5 | |
| 6 | package main |
| 7 | |
| 8 | import ( |
| 9 | "log" |
| 10 | "os" |
| 11 | |
| 12 | "github.com/bwplotka/bingo/builtin" |
| 13 | |
| 14 | "github.com/spf13/cobra" |
| 15 | ) |
| 16 | |
| 17 | var verbose bool |
| 18 | var moddir string |
| 19 | |
| 20 | func NewBingoCommand(logger *log.Logger) *cobra.Command { |
| 21 | cmd := &cobra.Command{ |
| 22 | Use: "bingo", |
| 23 | Long: `bingo: 'go get' like, simple CLI that allows automated versioning of |
| 24 | Go package level binaries (e.g required as dev tools by your project!) |
| 25 | |
| 26 | built on top of Go Modules, allowing reproducible dev environments. |
| 27 | 'bingo' allows to easily maintain a separate, nested Go Module for each binary. |
| 28 | |
| 29 | For detailed examples and documentation see: https://github.com/bwplotka/bingo |
| 30 | `, |
| 31 | } |
| 32 | flags := cmd.PersistentFlags() |
| 33 | flags.BoolVarP(&verbose, "verbose", "v", false, "Print more") |
| 34 | flags.StringVarP(&moddir, "moddir", "m", ".bingo", "Directory where separate modules for each binary will be maintained. \n"+ |
| 35 | "Feel free to commit this directory to your VCS to bond binary versions to your project code. \n"+ |
| 36 | "If the directory does not exist bingo logs and assumes a fresh project.") |
| 37 | cmd.AddCommand(NewBingoGetCommand(logger)) |
| 38 | cmd.AddCommand(NewBingoListCommand(logger)) |
| 39 | cmd.AddCommand(NewBingoVersionCommand()) |
| 40 | cmd.SetUsageTemplate(builtin.CommandHelpTemplate) |
| 41 | return cmd |
| 42 | } |
| 43 | |
| 44 | func main() { |
| 45 | logger := log.New(os.Stderr, "", 0) |
| 46 | rootCmd := NewBingoCommand(logger) |
| 47 | err := rootCmd.Execute() |
| 48 | if err != nil { |
| 49 | logger.Println(err) |
| 50 | os.Exit(1) |
| 51 | } |
| 52 | } |