help_usage Subroutine

subroutine help_usage(l_help)

Arguments

Type IntentOptional Attributes Name
logical, intent(in) :: l_help

Variables

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: help_text(:)
integer, public :: i
character(len=*), public, parameter :: ident = "@(#)help_usage(3f): prints help information"
logical, public :: stopit = .false.

Source Code

subroutine help_usage(l_help)
implicit none
character(len=*),parameter     :: ident="@(#)help_usage(3f): prints help information"
logical,intent(in)             :: l_help
character(len=:),allocatable :: help_text(:)
integer                        :: i
logical                        :: stopit=.false.
stopit=.false.
if(l_help)then
help_text=[ CHARACTER(LEN=128) :: &
'NAME                                                                            ',&
'   rand - [M_random] generate pseudo-random permutations of file lines, whole   ',&
'   numbers, or strings                                                          ',&
'   (LICENSE:PD)                                                                 ',&
'                                                                                ',&
'SYNOPSIS                                                                        ',&
'  syntax:                                                                       ',&
'                                                                                ',&
'   rand FILES(s)   [ -n]                                                        ',&
'   rand STRINGS -e [ -n]                                                        ',&
'   rand -i LO-HI   [ -n]                                                        ',&
'                                                                                ',&
'DESCRIPTION                                                                     ',&
'   Generates pseudorandom permutations, similar to the shuf(1) command.         ',&
'   Writes pseudo-random permutations of:                                        ',&
'                                                                                ',&
'   o the lines in a file                                                        ',&
'   o a range of whole numbers                                                   ',&
'   o a list of strings                                                          ',&
'                                                                                ',&
'OPTIONS                                                                         ',&
'   FILES(s)   files to use as input                                             ',&
'   -e         treat each ARG as an input line                                   ',&
'   -i LO HI   treat each number LO through HI as an input line                  ',&
'   -n         output at most COUNT lines (per file)                             ',&
'   --help     display this help and exit                                        ',&
'   --version  output version information and exit                               ',&
'                                                                                ',&
'EXAMPLES                                                                        ',&
'  Sample usage:                                                                 ',&
'                                                                                ',&
'   # generate a random number from 0 to 100                                     ',&
'   rand -i 0 100 -n 1                                                           ',&
'                                                                                ',&
'   # randomly pick a line from a file                                           ',&
'   rand -n 1 MYFILE.TXT                                                         ',&
'                                                                                ',&
'   # randomly select xterm(1) color                                             ',&
'   xterm -bg `rand green black gray blue -e -n 1`                               ',&
'                                                                                ',&
'   # randomly sleep 10 to 30 seconds                                            ',&
'   sleep `rand 10 30 -n 1`                                                      ',&
'                                                                                ',&
'AUTHOR                                                                          ',&
'   John S. Urban                                                                ',&
'                                                                                ',&
'LICENSE                                                                         ',&
'   Public Domain                                                                ',&
'                                                                                ',&
'']
   WRITE(*,'(a)')(trim(help_text(i)),i=1,size(help_text))
   stop ! if --help was specified, stop
endif
end subroutine help_usage