Command Line Syntax
I was trying to come up with some syntax which is simple, generic, and systematic by starting with asking myself "what does the command line do?" I think it serves as an interface between users and computer program so that users can give instructions to the system (one way communication). It includes three main tasks:
- Calling executable program (Binary file name):
- Selecting options for the program:
- Input main data:
This tells the computer system to which program to execute.
Some options take arguments, others don't. Some arguments in an option take other arguments. In such a case, these arguments are the 2nd layer options. These concepts can be expanded to N-layers. Thus, options can be imaged as a hierarchy with multiple layers. Program name is the root, option is the parent, argument is the child. Option separator separates option and argument (layer) while argument separator separate arguments for the same option.
In addition, some arguments are predefined and others are not. For examples:
< Example > lvg -fl -m
=> One argument (l) for option (f).
=> No argument for option (m).
=> "-" and "" are used as option separators.
< Example > lvg -fc:h
=> h is a predefined argument for 2nd layer option (c, which is a argument for f).
< Example > lvg -t2 -l
=> 2 is a non-predefined argument for option (t)
=> " " is used as the option separator.
Strictly speaking, main data can be categorized as option with 2 layers, such as "-input:main_data". However, if the main data is a required argument, we may want to make an exception for it to simply the syntax. For example:
< Example > lvg -Options:Argumnts -input:main_data
=> lvg -Options:Arguments main_data
In some case, such as in lvg, we insert main data after setting up and run the program. Thus, main data will not show in the command line.