-
Notifications
You must be signed in to change notification settings - Fork 267
Establish a convention for declaring CLI flags #301
Conversation
If we achieve consensus on this style, i will go ahead and update the rest of the codebase in this PR. |
Current coverage is 70.99% (diff: 0.00%)@@ master #301 diff @@
==========================================
Files 25 25
Lines 1243 1241 -2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 881 881
+ Misses 287 285 -2
Partials 75 75
|
Short: "Access flavor plugin", | ||
PersistentPreRunE: func(c *cobra.Command, args []string) error { | ||
} | ||
name := cmd.PersistentFlags().String("name", "", "Name of plugin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really need to be a PersistentFlags()
?
It doesn't seem that the name is passed down to any sub-children, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does need to be, as you want to specify a plugin name
for most of the subcommands being used. IMHO it really should be a positional (required) argument rather than a flag, but that's not something i'm willing to tackle in this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think having pointer deferences in the function bodies look a bit awkward. That said, if it's just a convention / pattern then I am ok with it. |
@chungers i agree, but i see it as a lesser of evils. IMHO this pattern reduces likelihood of subtle bugs for a net improvement. |
Signed-off-by: Bill Farner <bill@docker.com>
Signed-off-by: Bill Farner <bill@docker.com>
Signed-off-by: Bill Farner <bill@docker.com>
Please sign your commits following these rules: $ git clone -b "arg-var" git@github.com:wfarner/infrakit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354593776
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f Amending updates the existing PR. You DO NOT need to open a new one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Cloud federation
I'd like to propose this style as a convention for declaring CLI flags and associated variables. I like this since it eliminates the data flow cycle we frequently had otherwise (declare a zeroed var, refer to zeroed var for flag default, refer to var pointer for arg value).
Signed-off-by: Bill Farner bill@docker.com