Cobra subcommands
Posted: Wed Nov 03, 2010 11:03 pm
Tools like svn, git and hg have subcommands such as:
The general form is:
I'm thinking this would work well for Cobra which already effectively has subcommands including compile, run, test, document and highlight, and could gain more. Let's spell out some examples:
The above approach makes it trivial to have command-specific options.
I know hops already proposed something similar and also provided a patch. What I'm suggesting here is that the well known form currently used by the source code control clients is both well designed and familiar enough that we should adopt it for Cobra.
Did I miss any important examples or issues? Any feedback?
- Code: Select all
svn status -v somefile.txt
hg clone http://foo.com/bar
hg add somefile.txt
hg commit -m 'Comment'
The general form is:
- Code: Select all
<program> <global-options> <sub-command> <sub-command-options> <files>
I'm thinking this would work well for Cobra which already effectively has subcommands including compile, run, test, document and highlight, and could gain more. Let's spell out some examples:
- Code: Select all
# run (which implies compilation since you're passing in source)
cobra run Foo.cobra
# but run is also the default
cobra Foo.cobra
# passing args to your program
cobra Foo.cobra -- arg1 arg2
# compile only
cobra compile Foo.cobra
# commands often have abbreviations
cobra c Foo.cobra
# test
cobra -v test Foo.cobra Bar.cobra
# highlight
cobra highlight -styles:cobra Foo.cobra Bar.cobra
cobra highlight -styles:pygments Foo.cobra Bar.cobra
The above approach makes it trivial to have command-specific options.
I know hops already proposed something similar and also provided a patch. What I'm suggesting here is that the well known form currently used by the source code control clients is both well designed and familiar enough that we should adopt it for Cobra.
Did I miss any important examples or issues? Any feedback?