huntzhan / clidoc

Prove Of Conecept Fork Of Docopt.
MIT License
7 stars 1 forks source link

Preprocess input arguments. #29

Closed huntzhan closed 9 years ago

huntzhan commented 9 years ago

Purpose of preprocessing is to simplify the argv matching algorithm.

Order of actions:

  1. remove utility name.
  2. insert space between keywords(i.e. =, ,).[Guideline 8]
  3. tokenize intput arguments.
  4. check binding pairs indicated by =; remove appearance of =.
  5. handle --.(reuse #12)[Guideline 10]
  6. separate and disambiguate GROUPED_OPTIONS.(recuse #9 and #6)[Guideline 5, exceptions]
  7. replace each option with its representative option.

And finally, only three kinds of tokens would be passed to argv match algorithm:

  1. POSIX_OPTION.
  2. GNU_OPTION.
  3. GENERAL_ELEMENT.

Token with type of GENERAL_ELEMENT could be an option argument, or an operand, or a command.

huntzhan commented 9 years ago

drawbacks of argv processing in v0.1 are as follow:

such drawback should be overcame in v0.2.