aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-04-05 23:39:16 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-04-05 23:39:16 +0300
commit7936a03a898c50def8e2bd00494c804cc8b12cb3 (patch)
tree08398163e900c4f298cf4119b891107b9614eb1d
parent28703e5ece44fc886ec649c48ec1ed321c6a929e (diff)
Fix readme
-rw-r--r--README.md57
1 files changed, 56 insertions, 1 deletions
diff --git a/README.md b/README.md
index c3a697e..aa3ecb4 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,56 @@
-# app \ No newline at end of file
+# app
+
+[![Go Reference](https://pkg.go.dev/badge/github.com/neonxp/app.svg)](https://pkg.go.dev/github.com/neonxp/app)
+
+Simple cli applications runner.
+
+## Usage
+
+Commands must implements `app.Command` interface:
+
+```go
+type exampleCommand struct {
+ test string
+}
+
+func (c *exampleCommand) Name() string {
+ return "example"
+}
+
+func (c *exampleCommand) Usage() string {
+ return "just example command"
+}
+
+func (c *exampleCommand) Flags() *flag.FlagSet {
+ fs := flag.NewFlagSet(c.Name(), flag.ExitOnError)
+ fs.StringVar(&c.test, "test", "value", "test flag")
+ return fs
+}
+
+func (c *exampleCommand) Run(args []string) error {
+ fmt.Printf("Runned %s command with flag -test=%s and args: %v", c.Name(), c.test, args)
+ return nil
+}
+```
+
+Main file example:
+
+```go
+package main
+
+import "github.com/neonxp/app"
+
+func main() {
+ app := app.New([]app.Command{
+ exampleCommand{}, // <- Register command
+ })
+ if err := app.Start(os.Args); err != nil { // <- Run!
+ fmt.Println(err)
+ os.Exit(1)
+ }
+}
+```
+
+That's all!
+
+(/example/example.go)[Full example]