Command Line Syntax

I. Background

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:

  1. Calling executable program (Binary file name):

    This tells the computer system to which program to execute.

  2. Selecting options for the program:

    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, and 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.

  3. Input main data:

    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.