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