Save CLI usage as man page.
Type | Intent | Optional | 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. |
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