@@ -2,6 +2,7 @@ package cobra2snooty
2
2
3
3
import (
4
4
"bytes"
5
+ "fmt"
5
6
"io/ioutil"
6
7
"os"
7
8
"path/filepath"
@@ -52,11 +53,17 @@ func Echo() *cobra.Command {
52
53
return echoCmd
53
54
}
54
55
echoCmd = & cobra.Command {
55
- Use : "echo [ string to echo]" ,
56
+ Use : "echo < string to echo> [test param ]" ,
56
57
Aliases : []string {"say" },
57
58
Short : "Echo anything to the screen" ,
58
59
Long : "an utterly useless command for testing" ,
59
60
Example : "Just run root echo" ,
61
+ Annotations : map [string ]string {
62
+ "args" : "string to print, test param" ,
63
+ "requiredArgs" : "string to print" ,
64
+ "string to printDesc" : "A string to print" ,
65
+ "test paramDesc" : "just for testing" ,
66
+ },
60
67
}
61
68
echoCmd .PersistentFlags ().StringP ("strone" , "s" , "one" , "help message for flag strone" )
62
69
echoCmd .PersistentFlags ().BoolP ("persistentbool" , "p" , false , "help message for flag persistentbool" )
@@ -113,6 +120,9 @@ func TestGenDocs(t *testing.T) {
113
120
checkStringContains (t , output , Echo ().Example )
114
121
checkStringContains (t , output , "boolone" )
115
122
checkStringContains (t , output , "rootflag" )
123
+ //
124
+ checkStringContains (t , output , fmt .Sprintf (" * - string to print\n - string\n - true\n - %s\n " , Echo ().Annotations ["string to printDesc" ]))
125
+ checkStringContains (t , output , fmt .Sprintf (" * - test param\n - string\n - false\n - %s\n " , Echo ().Annotations ["test paramDesc" ]))
116
126
checkStringOmits (t , output , Root ().Short )
117
127
checkStringContains (t , output , EchoSubCmd ().Short )
118
128
checkStringOmits (t , output , deprecatedCmd .Short )
@@ -165,11 +175,11 @@ func TestGenTreeDocs(t *testing.T) {
165
175
defer os .RemoveAll (tmpdir )
166
176
167
177
if err := GenTreeDocs (c , tmpdir ); err != nil {
168
- t .Fatalf ("GenReSTTree failed: %s" , err .Error ())
178
+ t .Fatalf ("GenTreeDocs failed: %s" , err .Error ())
169
179
}
170
180
171
181
if _ , err := os .Stat (filepath .Join (tmpdir , "do.txt" )); err != nil {
172
- t .Fatalf ("Expected file 'do.rst ' to exist" )
182
+ t .Fatalf ("Expected file 'do.txt ' to exist" )
173
183
}
174
184
}
175
185
0 commit comments