Need some advice on CLI design, I need to provide simple but powerful command line options

  softwareengineering

I am writing a utility that runs on RHEL5 command line. I need my command line options to be simple but powerful. I looked at the various UNIX utilities to get an idea of how simple command line utilities have to be. Do you guys suggest any documents/links that talk about command line etiquette? I am modelling my utility on top of LVM (that’s all the info I can give for now). I know it’s a software engineering question, but I thought it would be appropriate to post here. Please advise….

PS: I am not asking for details about getopt or command line utility parsers…..

<what> <how> <which>

<what>: what you want to do. If your software does lots of different things, you might want to use different commands or command/subcommand (e.g. git pull, git push, etc.)

<how>: modifiers on what you want to do. Typically one switches/command-taking options (e.g. -s, -s <arg>). Most often used commands deserve one character identifiers- probably all commands should get long names (e.g. --short). -v/--verbose, -d/--debug, -n/--dry-run, -o/--out, -h/--help, -V/--version… there are quite a few commands which are somewhat standardized

<which> files/stuff are you operating on. - meaning stdin (or no args) should be provided if possible.

Interesting stuff:

  • If your command spits output, provide an option to generate machine-readable output
  • Use stdout/stderr correctly
  • Provide shell completion hooks
  • Provide man pages

You have started with:

need my command line options to be simple but powerful
modelling my utility on top of LVM(thats all the info I can give for now)

Good thing that’s not a tall-order request.

Since we don’t know what specific logical volume manager functions you are referring to, it’s hard to give specific examples of what to create for a command line option.

In general, you want to think about:
– commonly performed tasks
– steps required to perform those tasks
– how to simplify the steps and the tasks into single element

“Simple” is actually much more difficult to code. You will likely need to eliminate the hundreds of options that could be and focus on the ones that are needed.

To rephrase what you’re asking for is this: non-trivial and easy to use. Dig into your use cases; find the commonality; present a “single” option to reflect the commonality of that use case.

And / Or just write really solid documentation that thoroughly explains what the options will do. One fault I find with most man pages is that they’re usually great for reference, but difficult to learn from.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT