Command line option update

Ok, so I ended up compromising between Seth’s plan and mine.

The option name is still -p, but I’ve renamed the long form --host-pattern. -h is taken by opt parse for --help

The inventory file is now -i

-p options can be separated by semicolons and can be either host patterns (matching any host in the inventory file) or group names from the inventory file

I didn’t allow targeting hosts not in the file, because I believe this results in a confusing scenario if you typo a pattern or a group name, and it’s not readily apparent
nothing is matched.

I’ve updated the README and docs to reflect this.

It also seems we can eliminate “-a” if we use the unmatched args, so I’m working to incorporate that from Seth’s earlier patches. I also think defaulting -n to command is pretty elegant.

It bothers me that the default pattern is “*”, as that seems a thermonuclear option. So I am going to REQUIRE a value be supplied for -p. No default.

AKA:

ansible rm -rf /srv

VS

ansible -p “webservers” rm -rf /srv

In the latter, you made a conscious decision about what you were going to target. That walks a bit of a line between being crazy useful and very easy to shoot your foot off with.

–Michael

Actually this seems cleanest, because it uses arguments to be required. Required options is kind of an oxymoron anyway.

ansible [-n foo] [-a foo]

The command module will also be modified to fail with proper JSON if it receives no arguments.

Also, while I COULD also make arguments work outside of -a, I’d rather keep things explicit.

I am also renaming “-n” to “-m” since I think “module” better than I think “name”. Stay tuned, and check README.md tomorrow I guess :slight_smile:

CLI design is a path to madness.

–Michael