Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Man page & markdown built-in switches #99

Open
GHNewbiee opened this issue Jan 26, 2023 · 2 comments
Open

Man page & markdown built-in switches #99

GHNewbiee opened this issue Jan 26, 2023 · 2 comments
Assignees

Comments

@GHNewbiee
Copy link

GHNewbiee commented Jan 26, 2023

After considering the examples in the end, I wonder how the -mp and -md switches would be used if there were also required switches. For example:

$ ./program --required1 'some text' --required2 'some numbers' -mp -md

IMHO, both switches have nothing to do with the "flow" of the program. They both are like -h and -v. They produce a result out of the scope of the main program. Both -mp and -md switches would be built-in like -h and -v taking the progname from cli%init() as file name and 1 or md as file extensions.

If convenient, also two extra arguments manname and mdname would be added to cli%init() in favour of freedom.

Hence, just typing

$ ./program -mp -md

w/o any required switches will be more convenient and elegant.

Of course, current possibility of adding manually extra switches to get man page and markdown file names from CL are still available.

Tia

PS: Having default text for each required switch is not always convenient, especially in case a path is required; setting def = '' requires extra condition to stop the execution of the program.

Examples

...
character(99) :: manpage  !< Man page file name
character(99) :: markdown !< Markdown file name

call cli%init(...)

call cli%add(switch='--manpage',  switch_ab='-mp', help='man page file name', required=.false., act='store', def='program.1')
call cli%add(switch='--markdown', switch_ab='-md', help='markdown file name', required=.false., act='store', def='program.md')

call cli%get(switch='-mp', val=manpage)
call cli%get(switch='-md', val=markdown)

call cli%save_man_page(man_file=trim(manpage))
call cli%save_usage_to_markdown(markdown_file=trim(markdown))
$ ./program -mp -md

OR

...
logical :: manpage  !< Man page file name
logical :: markdown !< Markdown file name

call cli%init(...)

call cli%add(switch='--manpage',  switch_ab='-mp', help='man page file name', required=.false., act='store_true', def='.false.')
call cli%add(switch='--markdown', switch_ab='-md', help='markdown file name', required=.false., act='store_true', def='.false.')

call cli%get(switch='-mp', val=manpage)
call cli%get(switch='-md', val=markdown)

if (man .eqv. .true) call cli%save_man_page(man_file='program.1')
if (md  .eqv. .true) call cli%save_usage_to_markdown(markdown_file='program.md')
$ ./program -mp -md
@szaghi szaghi self-assigned this Jan 31, 2023
@szaghi
Copy link
Owner

szaghi commented Jan 31, 2023

@GHNewbiee

Nice suggestion, thank you very much. I'll try to work on it ASAP.

Kind regards

@jvdp1
Copy link
Contributor

jvdp1 commented Sep 22, 2023

Hi,
I support this idea too. Is there some progress on this issue? I could potentially help on this by mimicking the switches -h and -v.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants