Created
November 7, 2019 21:21
-
-
Save lobre/7bf8103e743290a3267f6b7401f15e19 to your computer and use it in GitHub Desktop.
Testing the cli kit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(¬eGroup) | |
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