I am redesigning a command line application and am looking for a way to make its use more intuitive. Are there any conventions for the format of parameters passed into a command line application? Or any other method that people have found useful?
相关问题
- JFX scale image up and down to parent
- softlinks atime and mtime modification
- Get unexpanded argument from bash command line
- Include and Execute EXE in C# Command Line App
- Batch - Set variables in for loop
相关文章
- Algorithm for maximizing coverage of rectangular a
- Compile and build with single command line Java (L
- Is there a way to hide the new HTML5 spinbox contr
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- PropertyGrid - Possible to have a file/directory s
- Programming a touch screen application with SWING
- Can WM_NEXTDLGCTL be used with non-dialog windows?
- How to update command line output?
I developed this framework, maybe it helps:
The SysCommand is a powerful cross-platform framework, to develop Console Applications in .NET. Is simple, type-safe, and with great influences of the MVC pattern.
https://github.com/juniorgasparotto/SysCommand
Tests:
One thing I like about certain CLI is the usage of shortcuts.
I.e, all the following lines are doing the same thing
That way, the user may not have to type the all command every time.
The conventions that you use for you application would depend on
1) What type of application it is.
2) What operating system you are using. Linux? Windows? They both have different conventions.
What I would suggest is look at other command line interfaces for other commands on your system, paying special attention to the parameters passed. Having incorrect parameters should give the user solution directed error message. An easy to find help screen can aid in usability as well.
Without know what exactly your application will do, it's hard to give specific examples.
-operation [parameters] -command [your command] -anotherthings [otherparams]....
For example,
Command line conventions vary from OS to OS, but the convention that's probably gotten both the most use, and the most public scrutiny is the one supported by the GNU getopt package. See http://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html for more info.
It allows you to mix single letter commands, such as -nr, with longer, self-documenting options, such as --numeric --reverse. Be nice, and implement a --help (-?) option and then your users will be able to figure out all they need to know.
A good and helpful reference:
https://commandline.codeplex.com/
Library available via NuGet:
Install-Package CommandLineParser
.Install-Package CommandLineParser -pre
.One line parsing using default singleton:
CommandLine.Parser.Default.ParseArguments(...)
.One line help screen generator:
HelpText.AutoBuild(...)
.Map command line arguments to
IList<string>
, arrays, enum or standard scalar types.Plug-In friendly architecture as explained here.
Define verb commands as
git commit -a
.Create parser instance using lambda expressions.
QuickStart: https://commandline.codeplex.com/wikipage?title=Quickstart&referringTitle=Documentation