szaghi / FLAP

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

unit number specification for usage and version output #61

Closed zbeekman closed 8 years ago

zbeekman commented 8 years ago

Hi Stefano, I would like to use FLAP with an MPI code, and it would be great (and great in general) for the user to be able to alter the behavior of the --help and --version switches. At first, I was thinking it would be wonderful to be able to override the default behavior of the two methods that get called when passing the switch. However, I think an even more useful feature would be to allow some extra arguments to the init method to specify optional file handles to be used for outputing --help and --version. Specifically I think --help should go out on error_unit and --version on output_unit. But letting the user override this would be very helpful.

In my case, with MPI I would have something like this:

if (rank == 0) then
  help_unit = error_unit
  version_unit = output_unit
else
  help_unit = null_unit ! open /dev/null somewhere above...
  version_unit = null_unit
end if
call cli%init( ... help_unit=help_unit, version_unit=version_unit, ... )

This way all MPI ranks can read the command line arguments passed in, but if the user wants a help or version print out, they won't get n_ranks copies of the requested output.

zbeekman commented 8 years ago

I will have PR soon for this...