gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dc_args::dcargshelp Interface Reference

Public Member Functions

subroutine dcargshelp0 (arg, force)
 

Detailed Description

Definition at line 303 of file dc_args.f90.

Member Function/Subroutine Documentation

◆ dcargshelp0()

subroutine dc_args::dcargshelp::dcargshelp0 ( type(args), intent(inout)  arg,
logical, intent(in), optional  force 
)

Auto-configure help option

Performs automatic configuration of the help option.

When any of -h, -H, –help is specified, automatically displays information configured in arg as a help message and then terminates the program. As a rule, please call DCArgsOption and DCArgsDebug subroutines before this subroutine.

If .true. is specified for force, the help message is displayed and the program is terminated even if -H, –help option is not given.

Information displayed in the help message can be added using DCArgsOption and DCArgsHelpMsg subroutines.

Parameters
[in,out]argARGS derived type variable
[in]forceIf .true., display help even without option (optional)

Definition at line 737 of file dc_args.f90.

738 use dc_types, only: string, stdout
741 use dc_message, only: messagenotify
743 implicit none
744 type(ARGS), intent(inout) :: arg
745 logical, intent(in), optional :: force
746 logical :: OPT_help, found, end
747 character(STRING) :: VAL_help, options_msg, help_msg, category
748 character(STRING), pointer :: localopts(:) => null()
749 integer :: unit, i
750 character(len = *), parameter :: subname = 'DCArgsHelp'
751 continue
752 if (.not. arg % initialized) then
753 call messagenotify('W', subname, 'Call Open before Help in dc_args.')
754 call dcargsopen(arg)
755 end if
756 call dcargsoption(arg, stoa('-h', '-H', '--help'), opt_help, val_help, &
757 & help="display this help and exit. " // &
758 & "VAL is unit number (default is standard output)")
759 if (.not. opt_help .and. .not. present_and_true(force)) then
760 return
761 end if
762 if (trim(val_help) == '') then
763 unit = stdout
764 else
765 unit = stoi(val_help)
766 end if
767
768 call printf(unit, '')
769
770 call dchashget(arg % helpmsg, 'TITLE', help_msg, found)
771 if (found) then
772 call printf(unit, '%c', c1=trim(help_msg))
773 call printf(unit, '')
774 call dchashdelete(arg % helpmsg, 'TITLE')
775 end if
776
777 call dchashget(arg % helpmsg, 'OVERVIEW', help_msg, found)
778 if (found) then
779 call printf(unit, 'Overview::')
780 call printautolinefeed(unit, help_msg, indent=' ')
781 call printf(unit, '')
782 call dchashdelete(arg % helpmsg, 'OVERVIEW')
783 end if
784
785 call dchashget(arg % helpmsg, 'USAGE', help_msg, found)
786 if (found) then
787 call printf(unit, 'Usage::')
788 call printautolinefeed(unit, help_msg, indent=' ')
789 call printf(unit, '')
790 call dchashdelete(arg % helpmsg, 'USAGE')
791 end if
792
793 call printf(unit, 'Options::')
794 if ( associated(arg % opt_table) ) then
795 do i = 1, size(arg % opt_table)
796 options_msg = ' '
797 if (arg % opt_table(i) % optvalue_flag) then
798 call concat(arg % opt_table(i) % options, '=VAL', localopts)
799 else
800 allocate(localopts(size(arg % opt_table(i) % options)))
801 localopts = arg % opt_table(i) % options
802 end if
803 options_msg = trim(options_msg) // trim(joinchar(localopts))
804 deallocate(localopts)
805 call printf(unit, ' %c', c1=trim(options_msg))
806 call printautolinefeed(unit, &
807 & arg % opt_table(i) % help_message, indent=' ')
808 call printf(unit, '')
809 end do
810 end if
811
812 call dchashrewind(arg % helpmsg)
813 do
814 call dchashnext(arg % helpmsg, category, help_msg, end)
815 if (end) exit
816
817 call printf(unit, '%c%c::', &
818 & c1=trim(uchar(category(1:1))), c2=trim(lchar(category(2:))))
819 call printautolinefeed(unit, help_msg, indent=' ')
820 call printf(unit, '')
821
822 enddo
823
824 call dcargsclose(arg)
825
826 stop
Hash (associative array) module.
Definition dc_hash.f90:143
Message output module.
Judge optional control parameters.
logical function, public present_and_true(arg)
Handling character types.
Definition dc_string.f90:83
character(string) function, public joinchar(carray, expr)
Provides kind type parameter values.
Definition dc_types.f90:55
integer, parameter, public stdout
Unit number for Standard OUTPUT
Definition dc_types.f90:117
integer, parameter, public string
Character length for string
Definition dc_types.f90:137

References dc_string::joinchar(), dc_present::present_and_true(), dc_types::stdout, and dc_types::string.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: