reject unsupported options and disable default input file name
This commit is contained in:
parent
01877fe909
commit
cb68140f62
1 changed files with 29 additions and 9 deletions
|
|
@ -35,22 +35,42 @@
|
|||
CHARACTER(100) :: num1char
|
||||
|
||||
!First, make sure the right number of inputs have been provided
|
||||
IF(COMMAND_ARGUMENT_COUNT().EQ.0)THEN
|
||||
! read from itape
|
||||
read_itape = .true.
|
||||
ELSE IF(COMMAND_ARGUMENT_COUNT().EQ.1)THEN
|
||||
IF(COMMAND_ARGUMENT_COUNT().EQ.1)THEN
|
||||
CALL GET_COMMAND_ARGUMENT(1,num1char) !first, read in the two values
|
||||
ELSE
|
||||
WRITE(*,*)'ERROR, TOO MANY COMMAND-LINE ARGUMENTS(MORE THAN ONE). STOPPING'
|
||||
STOP
|
||||
ENDIF
|
||||
|
||||
read_stdin = (num1char=="-")
|
||||
|
||||
IF(read_itape)THEN
|
||||
itape_name = "itape"
|
||||
WRITE(*,*) "Read from itape"
|
||||
ELSE IF(read_stdin)THEN
|
||||
IF(num1char(1:1) == "-") THEN
|
||||
|
||||
if(num1char=="-h") then
|
||||
write(*,'(a)') "usage: ex [-h] -|input_file"
|
||||
write(*,'(a)') ""
|
||||
write(*,'(a)') "positional arguments:"
|
||||
write(*,'(a)') " - read from std_in"
|
||||
write(*,'(a)') " input_file input file name"
|
||||
write(*,'(a)') ""
|
||||
write(*,'(a)') "optional arguments:"
|
||||
write(*,'(a)') " -h show this help message and exit"
|
||||
|
||||
stop
|
||||
else if (num1char=="-") then
|
||||
read_stdin = .true.
|
||||
else
|
||||
WRITE(*,*)'ERROR, UNSUPPORTED OPTION ', trim(num1char), '. STOPPING'
|
||||
STOP
|
||||
end if
|
||||
|
||||
ELSE
|
||||
|
||||
END IF
|
||||
|
||||
|
||||
|
||||
|
||||
IF(read_stdin)THEN
|
||||
WRITE(*,*) "Read from STDIN"
|
||||
ELSE
|
||||
itape_name = num1char
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue