Browse Source

En cours de développement

master
losyme 2 months ago
parent
commit
509a4c1f87
  1. 17
      cmdline.go

17
cmdline.go

@ -17,16 +17,14 @@ import (
const ErrStopApplication = errors.Sentinel("stop application")
type CmdLine struct {
app *application.Application
usage string
cmds map[string]*Cmd
app *application.Application
cmds map[string]*Cmd
}
func New(app *application.Application, usage string) *CmdLine {
func New(app *application.Application) *CmdLine {
cl := &CmdLine{
app: app,
usage: usage,
cmds: make(map[string]*Cmd),
app: app,
cmds: make(map[string]*Cmd),
}
// default help command
@ -77,7 +75,9 @@ func (c *CmdLine) Execute(args []string) error {
}
func (c *CmdLine) cmdHelp() error {
fmt.Printf("%s\n\n%s\n\n", c.app.Name(), c.usage)
app := c.app
fmt.Printf("%s\n\n%s\n\n", app.Name(), app.Usage())
usage(c.cmds, 0)
fmt.Println()
@ -86,6 +86,7 @@ func (c *CmdLine) cmdHelp() error {
func (c *CmdLine) cmdVersion() error {
app := c.app
fmt.Printf(
"%s: v%s (%s/%s/%s)\n\n",
app.Name(), app.Version(), app.BuiltAt().Format("2006-01-02 15:04:05"), runtime.GOARCH, runtime.GOOS,

Loading…
Cancel
Save