Skip to content

Commit 781c982

Browse files
printing functions
1 parent 8c40bf5 commit 781c982

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

cli.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"flag"
55
"fmt"
66
"github.com/digitalghost-dev/poke-cli/cmd"
7+
"github.com/digitalghost-dev/poke-cli/cmd/ability"
78
"github.com/digitalghost-dev/poke-cli/cmd/move"
9+
"github.com/digitalghost-dev/poke-cli/cmd/natures"
810
"github.com/digitalghost-dev/poke-cli/cmd/search"
911
"github.com/digitalghost-dev/poke-cli/cmd/types"
1012
"github.com/digitalghost-dev/poke-cli/flags"
@@ -22,7 +24,7 @@ func currentVersion() {
2224
return
2325
}
2426

25-
// Fallback to build info when version is not set
27+
// Fallback to build info when the version is not set
2628
buildInfo, ok := debug.ReadBuildInfo()
2729
if !ok {
2830
fmt.Println("Version: unknown (unable to read build info)")
@@ -36,6 +38,12 @@ func currentVersion() {
3638
}
3739
}
3840

41+
func printWrapper(f func() string) func() {
42+
return func() {
43+
fmt.Println(f())
44+
}
45+
}
46+
3947
func runCLI(args []string) int {
4048
mainFlagSet := flag.NewFlagSet("poke-cli", flag.ContinueOnError)
4149

@@ -89,9 +97,9 @@ func runCLI(args []string) int {
8997
}
9098

9199
commands := map[string]func(){
92-
"ability": cmd.AbilityCommand,
93-
"move": move.MoveCommand,
94-
"natures": cmd.NaturesCommand,
100+
"ability": printWrapper(ability.AbilityCommand),
101+
"move": printWrapper(move.MoveCommand),
102+
"natures": printWrapper(natures.NaturesCommand),
95103
"pokemon": cmd.PokemonCommand,
96104
"types": types.TypesCommand,
97105
"search": search.SearchCommand,

0 commit comments

Comments
 (0)