gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dc_args::help Interface Reference

Public Member Functions

subroutine dcargshelp0 (arg, force)

Detailed Description

Definition at line 346 of file dc_args.f90.

Member Function/Subroutine Documentation

◆ dcargshelp0()

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

ヘルプオプションの自動設定

ヘルプオプションの自動設定を行います.

-h, -H, –help のいづれかが指定された際, 自動的に arg 内に設定された 情報をヘルプメッセージとして表示した後, プログラムを終了させます. 原則的に, このサブルーチンよりも前に DCArgsOption, DCArgsDebug のサブルーチンを呼んで下さい.

force.true. が指定される場合, -H, –help オプションが与え られない場合でもヘルプメッセージを表示した後, プログラムを終了さ せます.

ヘルプメッセージに表示される情報は, DCArgsOption, DCArgsHelpMsg サブルーチンによって付加することが可能です.

Parameters
[in,out]argARGS 型変数
[in]force.true. の場合, オプション無しでもヘルプを表示 (省略可能)

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
ハッシュ (連想配列) モジュール
Definition dc_hash.f90:143
メッセージの出力
省略可能な制御パラメータの判定
logical function, public present_and_true(arg)
文字型変数の操作
Definition dc_string.f90:83
character(string) function, public joinchar(carray, expr)
種別型パラメタを提供します。
Definition dc_types.f90:55
integer, parameter, public string
文字列を保持する 文字型変数の種別型パラメタ
Definition dc_types.f90:137
integer, parameter, public stdout
標準出力の装置番号
Definition dc_types.f90:117

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