-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (62 loc) · 1.54 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"errors"
"fmt"
"os"
"github.com/fatih/color"
"github.com/fioncat/roxide/build"
"github.com/fioncat/roxide/cmd"
"github.com/fioncat/roxide/cmd/create"
"github.com/fioncat/roxide/cmd/get"
"github.com/fioncat/roxide/cmd/logs"
"github.com/fioncat/roxide/cmd/open"
"github.com/fioncat/roxide/cmd/remove"
"github.com/fioncat/roxide/cmd/switchcmd"
rerrors "github.com/fioncat/roxide/pkg/errors"
"github.com/mattn/go-isatty"
"github.com/spf13/cobra"
)
func newCmd() *cobra.Command {
c := &cobra.Command{
Use: "roxide",
Short: "Manage your git repositories",
SilenceErrors: true,
SilenceUsage: true,
// Completion is impletemented by `init` command, so disable this
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
Version: build.Version,
}
c.AddCommand(cmd.NewAttach())
c.AddCommand(cmd.NewConfig())
c.AddCommand(cmd.NewDetach())
c.AddCommand(cmd.NewDisplay())
c.AddCommand(cmd.NewHome())
c.AddCommand(cmd.NewInit())
c.AddCommand(cmd.NewMerge())
c.AddCommand(cmd.NewRebase())
c.AddCommand(cmd.NewSquash())
c.AddCommand(cmd.NewSync())
c.AddCommand(create.New())
c.AddCommand(get.New())
c.AddCommand(logs.New())
c.AddCommand(open.New())
c.AddCommand(remove.New())
c.AddCommand(switchcmd.New())
return c
}
func main() {
color.NoColor = false
if !isatty.IsTerminal(os.Stderr.Fd()) {
color.NoColor = true
}
c := newCmd()
err := c.Execute()
if err != nil {
if !errors.Is(err, rerrors.ErrSilenceExit) {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
}
os.Exit(1)
}
}