Positional vs optional arguments vs consistency

John Arbash Meinel john at arbash-meinel.com
Sat Nov 23 05:50:19 UTC 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd like to bring up the discussion of what guidelines we're using
when we design CLI commands. There are 2 commands that just came up
that I'd like to use as examples, and see what we think of as a team.

1) juju set-constraints [-s service] [key=value]
vs juju get-constraints [service]

In this case service *is* optional (if you don't supply it you get the
environment constraints). It is supplied as a positional argument to
get-constraints IMO because there was nothing else to conflict with.
But it would potentially be confusing to parse the command line for
set-constraints (is this a constraint we don't know about or a service
name?) So we supply the "-s" flag.

I'd like to make the case that "juju get-constraints -s service" would
actually fit better than as a positional argument. Mostly because then
it is consistent with "juju set-constraints"

2) juju destroy-environment [envname]

This one is probably a bit more controversial, and my opinion is
slightly based on how I actually use juju.

The main thing here is every command except for "juju
destroy-environment" takes the environment as a "-e envname"
parameter. Now *I* purposefully don't set a default environment (nor
use switch or JUJU_ENV). Instead I pass the environment I want the
action to occur to each command. (juju bootstrap -e amz-jam; juju
deploy -e amz-jam foobar).

Am I just unique in this? I can see where if you *aren't* used to
passing the '-e' flag to commands, then you haven't really
internalized that "to pass an environment I do -e ENV". And only
because I do, does it seem backwards that I *wouldn't* pass -e to juju
destroy-environment.

I can understand the "required arguments should be positional, not
flags". However, I also feel that this breaks the argument for
consistency of parameters across commands.

Thoughts?

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlKQQhsACgkQJdeBCYSNAAPnJACgn9WqsDJGjfUT/+YeV7SgBCs/
5YcAoINckYsZ3lV/gtb4ML0IFdlD1GVb
=NSrO
-----END PGP SIGNATURE-----



More information about the Juju-dev mailing list