Skip to content

Instantly share code, notes, and snippets.

@lobre
Created November 7, 2019 21:21
Show Gist options
  • Save lobre/7bf8103e743290a3267f6b7401f15e19 to your computer and use it in GitHub Desktop.
Save lobre/7bf8103e743290a3267f6b7401f15e19 to your computer and use it in GitHub Desktop.
Testing the cli kit
package main
import (
"flag"
"fmt"
"github.com/lobre/kits/cli"
)
func main() {
app := cli.New()
noteGroup := cli.Group{
Name: "notes",
}
echoCmd := cli.Cmd{
Name: "echo",
Run: echo,
}
noteGroup.AddCmd(&echoCmd)
lsCmd := cli.Cmd{
Name: "ls",
Run: ls,
}
app.AddGroup(&noteGroup)
app.RootGroup().AddCmd(&lsCmd)
app.Run()
}
func echo(fs *flag.FlagSet) error {
fmt.Println("echo specific file")
return nil
}
func ls(fs *flag.FlagSet) error {
fmt.Println("ls all files")
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment