-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
93 lines (80 loc) · 2.26 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"github.com/blocktree/beam-adapter/commands"
"gopkg.in/urfave/cli.v1"
"os"
"path/filepath"
"sort"
)
const (
Identifier = "openw-beam" // Client identifier to advertise over the network
)
var (
CommandHelpTemplate = `{{.cmd.Name}}{{if .cmd.Subcommands}} command{{end}}{{if .cmd.Flags}} [command options]{{end}} [arguments...]
{{if .cmd.Description}}{{.cmd.Description}}
{{end}}{{if .cmd.Subcommands}}
SUBCOMMANDS:
{{range .cmd.Subcommands}}{{.cmd.Name}}{{with .cmd.ShortName}}, {{.cmd}}{{end}}{{ "\t" }}{{.cmd.Usage}}
{{end}}{{end}}{{if .categorizedFlags}}
{{range $idx, $categorized := .categorizedFlags}}{{$categorized.Name}} OPTIONS:
{{range $categorized.Flags}}{{"\t"}}{{.}}
{{end}}
{{end}}{{end}}`
// Git SHA1 commit hash of the release (set via linker flags)
// The app that holds all commands and flags.
app = NewApp(commands.GitRev, "the beam wallet server command line interface")
)
func init() {
cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
VERSION:
{{.Version}}
COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
{{end}}{{end}}
`
cli.CommandHelpTemplate = CommandHelpTemplate
}
// NewApp creates an app with sane defaults.
func NewApp(gitCommit, usage string) *cli.App {
app := cli.NewApp()
app.Name = filepath.Base(os.Args[0])
app.Author = ""
//app.Authors = nil
app.Email = ""
app.Version = commands.Version
if len(gitCommit) >= 0 {
app.Version += "-" + gitCommit
}
app.Usage = usage
return app
}
func init() {
// Initialize the CLI app and start openw-cli
app.Name = Identifier
app.Action = openwbeam
app.HideVersion = true // we have a command to print the version
app.Copyright = "Copyright 2019 The OpenWallet Authors"
app.Version = commands.Version
app.Commands = commands.Commands
app.Flags = []cli.Flag{
commands.AppNameFlag,
commands.LogDirFlag,
commands.DebugFlag,
commands.ConfFlag,
}
sort.Sort(cli.CommandsByName(app.Commands))
}
func main() {
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
//openwbeam
func openwbeam(ctx *cli.Context) error {
return nil
}