@@ -54,15 +54,7 @@ func newSurgeryRevertMetaPageCommand() *cobra.Command {
54
54
revertMetaPageCmd := & cobra.Command {
55
55
Use : "revert-meta-page <bbolt-file> [options]" ,
56
56
Short : "Revert the meta page to revert the changes performed by the latest transaction" ,
57
- Args : func (cmd * cobra.Command , args []string ) error {
58
- if len (args ) == 0 {
59
- return errors .New ("db file path not provided" )
60
- }
61
- if len (args ) > 1 {
62
- return errors .New ("too many arguments" )
63
- }
64
- return nil
65
- },
57
+ Args : cobra .ExactArgs (1 ),
66
58
RunE : func (cmd * cobra.Command , args []string ) error {
67
59
if err := o .Validate (); err != nil {
68
60
return err
@@ -121,15 +113,7 @@ func newSurgeryCopyPageCommand() *cobra.Command {
121
113
copyPageCmd := & cobra.Command {
122
114
Use : "copy-page <bbolt-file> [options]" ,
123
115
Short : "Copy page from the source page Id to the destination page Id" ,
124
- Args : func (cmd * cobra.Command , args []string ) error {
125
- if len (args ) == 0 {
126
- return errors .New ("db file path not provided" )
127
- }
128
- if len (args ) > 1 {
129
- return errors .New ("too many arguments" )
130
- }
131
- return nil
132
- },
116
+ Args : cobra .ExactArgs (1 ),
133
117
RunE : func (cmd * cobra.Command , args []string ) error {
134
118
if err := o .Validate (); err != nil {
135
119
return err
@@ -193,15 +177,7 @@ func newSurgeryClearPageCommand() *cobra.Command {
193
177
clearPageCmd := & cobra.Command {
194
178
Use : "clear-page <bbolt-file> [options]" ,
195
179
Short : "Clears all elements from the given page, which can be a branch or leaf page" ,
196
- Args : func (cmd * cobra.Command , args []string ) error {
197
- if len (args ) == 0 {
198
- return errors .New ("db file path not provided" )
199
- }
200
- if len (args ) > 1 {
201
- return errors .New ("too many arguments" )
202
- }
203
- return nil
204
- },
180
+ Args : cobra .ExactArgs (1 ),
205
181
RunE : func (cmd * cobra.Command , args []string ) error {
206
182
if err := o .Validate (); err != nil {
207
183
return err
@@ -268,15 +244,7 @@ func newSurgeryClearPageElementsCommand() *cobra.Command {
268
244
clearElementCmd := & cobra.Command {
269
245
Use : "clear-page-elements <bbolt-file> [options]" ,
270
246
Short : "Clears elements from the given page, which can be a branch or leaf page" ,
271
- Args : func (cmd * cobra.Command , args []string ) error {
272
- if len (args ) == 0 {
273
- return errors .New ("db file path not provided" )
274
- }
275
- if len (args ) > 1 {
276
- return errors .New ("too many arguments" )
277
- }
278
- return nil
279
- },
247
+ Args : cobra .ExactArgs (1 ),
280
248
RunE : func (cmd * cobra.Command , args []string ) error {
281
249
if err := o .Validate (); err != nil {
282
250
return err
0 commit comments