forked from leaanthony/clir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclir.go
28 lines (25 loc) · 748 Bytes
/
clir.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
// Package clir provides a simple API for creating command line apps
package clir
import (
"fmt"
)
// defaultBannerFunction prints a banner for the application.
// If version is a blank string, it is ignored.
func defaultBannerFunction(c *Cli) string {
version := ""
if len(c.Version()) > 0 {
version = " " + c.Version()
}
return fmt.Sprintf("%s%s - %s", c.Name(), version, c.ShortDescription())
}
// NewCli - Creates a new Cli application object
func NewCli(name, description, version string) *Cli {
result := &Cli{
version: version,
bannerFunction: defaultBannerFunction,
}
result.rootCommand = NewCommand(name, description)
result.rootCommand.setApp(result)
result.rootCommand.setParentCommandPath("")
return result
}