55 "os"
66
77 "github.com/huangsam/namigo/cmd/namigo/sub"
8+ "github.com/huangsam/namigo/internal/model"
89 "github.com/urfave/cli/v2"
910)
1011
@@ -38,26 +39,16 @@ func main() {
3839 Usage : "Target interests" ,
3940 },
4041 & cli.IntFlag {
41- Name : "count" ,
42- Usage : "Maximum count of names" ,
43- Value : 10 ,
44- Action : func (ctx * cli.Context , i int ) error {
45- if i <= 0 {
46- return fmt .Errorf ("count %d is invalid" , i )
47- }
48- return nil
49- },
42+ Name : "count" ,
43+ Usage : "Maximum count of names" ,
44+ Value : 10 ,
45+ Action : checkCountFlag ,
5046 },
5147 & cli.IntFlag {
52- Name : "length" ,
53- Usage : "Maximum length for each name" ,
54- Value : 20 ,
55- Action : func (ctx * cli.Context , i int ) error {
56- if i <= 0 {
57- return fmt .Errorf ("length %d is invalid" , i )
58- }
59- return nil
60- },
48+ Name : "length" ,
49+ Usage : "Maximum length for each name" ,
50+ Value : 20 ,
51+ Action : checkLengthFlag ,
6152 },
6253 },
6354 Action : sub .GeneratePromptAction ,
@@ -69,26 +60,16 @@ func main() {
6960 Usage : "Search for terms across entities" ,
7061 Flags : []cli.Flag {
7162 & cli.IntFlag {
72- Name : "count" ,
73- Usage : "Maximum count of results" ,
74- Value : 10 ,
75- Action : func (ctx * cli.Context , i int ) error {
76- if i <= 0 {
77- return fmt .Errorf ("count %d is invalid" , i )
78- }
79- return nil
80- },
63+ Name : "count" ,
64+ Usage : "Maximum count of results" ,
65+ Value : 10 ,
66+ Action : checkCountFlag ,
8167 },
8268 & cli.StringFlag {
83- Name : "format" ,
84- Usage : "Output format can be text or json" ,
85- Value : "text" ,
86- Action : func (ctx * cli.Context , s string ) error {
87- if s != "text" && s != "json" {
88- return fmt .Errorf ("format %s is invalid" , s )
89- }
90- return nil
91- },
69+ Name : "format" ,
70+ Usage : fmt .Sprintf ("Output format can be %s or %s" , model .TextValue , model .JSONValue ),
71+ Value : model .TextValue ,
72+ Action : checkFormatFlag ,
9273 },
9374 },
9475 Subcommands : []* cli.Command {
0 commit comments