save_man_page Subroutine

private subroutine save_man_page(self, man_file, error)

Save CLI usage as man page.

Type Bound

command_line_interface

Arguments

Type IntentOptional Attributes Name
class(command_line_interface), intent(in) :: self

CLI data.

character(len=*), intent(in) :: man_file

Output file name for saving man page.

integer(kind=I4P), intent(out), optional :: error

Error trapping flag.


Calls

proc~~save_man_page~~CallsGraph proc~save_man_page flap_command_line_interface_t::command_line_interface%save_man_page proc~signature~3 flap_command_line_interface_t::command_line_interface%signature proc~save_man_page->proc~signature~3 proc~usage~3 flap_command_line_interface_t::command_line_interface%usage proc~save_man_page->proc~usage~3 strz strz proc~save_man_page->strz proc~signature flap_command_line_arguments_group_t::command_line_arguments_group%signature proc~signature~3->proc~signature proc~usage~3->proc~signature~3 proc~usage flap_command_line_arguments_group_t::command_line_arguments_group%usage proc~usage~3->proc~usage proc~signature~2 flap_command_line_argument_t::command_line_argument%signature proc~signature->proc~signature~2 proc~usage->proc~signature proc~usage~2 flap_command_line_argument_t::command_line_argument%usage proc~usage->proc~usage~2 cton cton proc~signature~2->cton proc~has_choices flap_command_line_argument_t::command_line_argument%has_choices proc~signature~2->proc~has_choices str str proc~signature~2->str proc~usage~2->cton interface~colorize face::colorize proc~usage~2->interface~colorize proc~replace_all flap_utils_m::replace_all proc~usage~2->proc~replace_all proc~usage~2->str proc~colorize_default face::colorize_default interface~colorize->proc~colorize_default proc~replace flap_utils_m::replace proc~replace_all->proc~replace proc~wstrip flap_utils_m::wstrip proc~replace_all->proc~wstrip proc~color_index face::color_index proc~colorize_default->proc~color_index proc~style_index face::style_index proc~colorize_default->proc~style_index proc~upper face::upper proc~colorize_default->proc~upper

Called by

proc~~save_man_page~~CalledByGraph proc~save_man_page flap_command_line_interface_t::command_line_interface%save_man_page program~flap_save_man_page flap_save_man_page program~flap_save_man_page->proc~save_man_page program~flap_test_basic flap_test_basic program~flap_test_basic->proc~save_man_page

Source Code

  subroutine save_man_page(self, man_file, error)
  !< Save CLI usage as man page.
  class(command_line_interface), intent(in)  :: self               !< CLI data.
  character(*),                  intent(in)  :: man_file           !< Output file name for saving man page.
  integer(I4P), optional,        intent(out) :: error              !< Error trapping flag.
  character(len=:), allocatable              :: man                !< Man page.
  integer(I4P)                               :: idate(1:8)         !< Integer array for handling the date.
  integer(I4P)                               :: e                  !< Counter.
  integer(I4P)                               :: u                  !< Unit file handler.
  character(*), parameter                    :: month(12)=["Jan",&
                                                           "Feb",&
                                                           "Mar",&
                                                           "Apr",&
                                                           "May",&
                                                           "Jun",&
                                                           "Jul",&
                                                           "Aug",&
                                                           "Sep",&
                                                           "Oct",&
                                                           "Nov",&
                                                           "Dec"]  !< Months list.

  call date_and_time(values=idate)
  man = '.TH '//self%progname//' "1" "'//month(idate(2))//' '//trim(adjustl(strz(idate(1),4)))//'" "version '//self%version//&
    '" "'//self%progname//' Manual"'
  man = man//new_line('a')//'.SH NAME'
  man = man//new_line('a')//self%progname//' - manual page for '//self%progname//' version '//self%version
  man = man//new_line('a')//'.SH SYNOPSIS'
  man = man//new_line('a')//'.B '//self%progname//new_line('a')//trim(adjustl(self%signature()))
  if (self%description /= '') man = man//new_line('a')//'.SH DESCRIPTION'//new_line('a')//self%description
  if (self%clasg(0)%Na>0) then
    man = man//new_line('a')//'.SH OPTIONS'
    man = man//new_line('a')//self%usage(no_header=.true.,no_examples=.true.,no_epilog=.true.,g=0)
  endif
  if (allocated(self%examples)) then
    man = man//new_line('a')//'.SH EXAMPLES'
    man = man//new_line('a')//'.PP'
    man = man//new_line('a')//'.nf'
    man = man//new_line('a')//'.RS'
    do e=1, size(self%examples,dim=1)
      man = man//new_line('a')//trim(self%examples(e))
    enddo
    man = man//new_line('a')//'.RE'
    man = man//new_line('a')//'.fi'
    man = man//new_line('a')//'.PP'
  endif
  if (self%authors /= '') man = man//new_line('a')//'.SH AUTHOR'//new_line('a')//self%authors
  if (self%license /= '') man = man//new_line('a')//'.SH COPYRIGHT'//new_line('a')//self%license
  open(newunit=u,file=trim(adjustl(man_file)))
  if (present(error)) then
    write(u, "(A)", iostat=error)man
  else
    write(u, "(A)")man
  endif
  close(u)
  endsubroutine save_man_page