szaghi / FLAP

Fortran command Line Arguments Parser for poor people
151 stars 34 forks source link

Make FLAP CLI Posix compliant #13

Closed szaghi closed 9 years ago

szaghi commented 9 years ago

FLAP has (presently) a CLI output looking very "personal"... It is better to change the default "appearance" in order to make it more close to a compliant POSIX CLI.

References:

zbeekman commented 9 years ago

+1 for posix compliance

szaghi commented 9 years ago

Thank you Izaak,

I have just uploaded a new version (0.0.5) aimed to be more POSIX compliant; if you run the test-driver program with the default settings it looks like:

default help

usage:  Test_Driver  [value] --string value [--integer value] [--real value] [--boolean] [--boolean_val value] [--integer_list value#1 value#2 value#3] [--help] [--version]

 Required options:
   --string value, -s value
       String input; required

 Optional options:
   value
       Positional real input; 1-th positional CLA; optional, default value 1.0
   --integer value, -i value, value in: (1,3,5)
       Integer input with fixed range; optional, default value 1
   --real value, -r value
       Real input; optional, default value 1.0
   --boolean, -b
       Boolean input; optional, default value .false.
   --boolean_val value, -bv value
       Valued boolean input; optional, default value .true.
   --integer_list value#1 value#2 value#3, -il value#1 value#2 value#3
       Integer list input; optional, default value 1 8 32
   --help, -h
       Print this help message; optional
   --version, -v
       Print version; optional

 Examples:
   -) Test_Driver -s 'Hello FLAP'
   -) Test_Driver -s 'Hello FLAP' -i -2 # printing error...
   -) Test_Driver -s 'Hello FLAP' -i 3 -r 33.d0
   -) Test_Driver -s 'Hello FLAP' --integer_list 10 -3 87
   -) Test_Driver 33.0 -s 'Hello FLAP' -i 5
   -) Test_Driver --string 'Hello FLAP' --boolean

wrong required arguments numbers

Test_Driver: error: too few arguments (0) respect the required (1)
usage:  Test_Driver  [value] --string value [--integer value] [--real value] [--boolean] [--boolean_val value] [--integer_list value#1 value#2 value#3] [--help] [--version]

 Required options:
   --string value, -s value
       String input; required

 Optional options:
   value
       Positional real input; 1-th positional CLA; optional, default value 1.0
   --integer value, -i value, value in: (1,3,5)
       Integer input with fixed range; optional, default value 1
   --real value, -r value
       Real input; optional, default value 1.0
   --boolean, -b
       Boolean input; optional, default value .false.
   --boolean_val value, -bv value
       Valued boolean input; optional, default value .true.
   --integer_list value#1 value#2 value#3, -il value#1 value#2 value#3
       Integer list input; optional, default value 1 8 32
   --help, -h
       Print this help message; optional
   --version, -v
       Print version; optional

 Examples:
   -) Test_Driver -s 'Hello FLAP'
   -) Test_Driver -s 'Hello FLAP' -i -2 # printing error...
   -) Test_Driver -s 'Hello FLAP' -i 3 -r 33.d0
   -) Test_Driver -s 'Hello FLAP' --integer_list 10 -3 87
   -) Test_Driver 33.0 -s 'Hello FLAP' -i 5
   -) Test_Driver --string 'Hello FLAP' --boolean

Do you such an appearance? Do you have any suggestions?

My best regards.

szaghi commented 9 years ago

I am going to close this issue. I have not found a clear "STANDARD", rather some guidelines. Now the appearance looks more like many other POSIX tools. I am satisfied.

zbeekman commented 9 years ago

Looks good to me. IIRC I think posix long options are supposed to be separated from their arguments with = rather than a space, but I could be wrong, and things look good the way they are, so I would’t change things from the way they are now.

szaghi commented 9 years ago

Thank you Izaak, your opinion is always interesting for me!