Save CLI usage as markdown.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(command_line_interface), | intent(in) | :: | self |
CLI data. |
||
character(len=*), | intent(in) | :: | markdown_file |
Output file name for saving man page. |
||
integer(kind=I4P), | intent(out), | optional | :: | error |
Error trapping flag. |
subroutine save_usage_to_markdown(self, markdown_file, error) !< Save CLI usage as markdown. class(command_line_interface), intent(in) :: self !< CLI data. character(*), intent(in) :: markdown_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 = '# '//self%progname//new_line('a') man = man//new_line('a')//'Manual page for `'//self%progname//'` version '//self%version//new_line('a') man = man//new_line('a')//'`'//self%progname//' '//trim(adjustl(self%signature()))//'`'//new_line('a') man = man//new_line('a')//month(idate(2))//' '//trim(adjustl(strz(idate(1),4)))//new_line('a') if (self%description /= '') man = man//new_line('a')//'### Short description'//new_line('a')//new_line('a')//self%description if (self%clasg(0)%Na>0) then man = man//new_line('a')//new_line('a')//'### Command line options:' man = man//self%usage(no_header=.true.,no_examples=.true.,no_epilog=.true.,g=0,markdown=.true.) endif if (allocated(self%examples)) then man = man//new_line('a')//new_line('a')//'### Examples' do e=1, size(self%examples,dim=1) man = man//new_line('a') man = man//new_line('a')//'`'//trim(self%examples(e))//'` ' enddo endif open(newunit=u,file=trim(adjustl(markdown_file))) if (present(error)) then write(u, "(A)", iostat=error)man else write(u, "(A)")man endif close(u) endsubroutine save_usage_to_markdown