dm_arg Module

Class for command-line argument parsing.

Create an arg object, then read and parse the arguments:

character(len=72) :: input
integer           :: delay, rc
logical           :: verbose
type(arg_class)   :: arg

call arg%create()
call arg%add('input',   short='i', type=ARG_TYPE_STRING, required=.true.)
call arg%add('delay',   short='x', type=ARG_TYPE_INTEGER)
call arg%add('verbose', short='V', type=ARG_TYPE_LOGICAL)

rc = arg%read()
call dm_error_out(rc)

call arg%get('input',  input)
call arg%get('delay',  delay)
call arg%get('verbose, verbose)
call arg%destroy()

Each argument requires name and type. The default type is ARG_TYPE_LOGICAL. The command-line arguments --help/-h and --version/-v are processed automatically by method read().

Additionally, you can pass a callback routine of abstract interface dm_arg_version_callback() to read() that outputs the version string.


Uses

  • module~~dm_arg~~UsesGraph module~dm_arg dm_arg module~dm_ascii dm_ascii module~dm_arg->module~dm_ascii module~dm_error dm_error module~dm_arg->module~dm_error module~dm_file dm_file module~dm_arg->module~dm_file module~dm_kind dm_kind module~dm_arg->module~dm_kind module~dm_util dm_util module~dm_arg->module~dm_util module~dm_error->module~dm_ascii module~dm_error->module~dm_kind module~dm_file->module~dm_error module~dm_file->module~dm_kind iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env module~dm_util->module~dm_error module~dm_util->module~dm_kind

Used by

  • module~~dm_arg~~UsedByGraph module~dm_arg dm_arg module~dmpack dmpack module~dmpack->module~dm_arg

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: ARG_TYPE_NONE = 0

None type (invalid).

integer, public, parameter :: ARG_TYPE_LOGICAL = 1

Logical argument.

integer, public, parameter :: ARG_TYPE_INTEGER = 2

Integer value.

integer, public, parameter :: ARG_TYPE_REAL = 3

Real value.

integer, public, parameter :: ARG_TYPE_CHAR = 4

Single character value.

integer, public, parameter :: ARG_TYPE_STRING = 5

Character string value.

integer, public, parameter :: ARG_TYPE_ID = 6

Valid ID value.

integer, public, parameter :: ARG_TYPE_UUID = 7

Valid UUIDv4 value.

integer, public, parameter :: ARG_TYPE_TIME = 8

Valid ISO 8601 value.

integer, public, parameter :: ARG_TYPE_LEVEL = 9

Log level (name string or integer value).

integer, public, parameter :: ARG_TYPE_FILE = 10

Path to file on file system (must exist).

integer, public, parameter :: ARG_TYPE_DATABASE = 11

Path to database on file system (must exist).

integer, public, parameter :: ARG_TYPE_LAST = 11

Never use this.

integer, public, parameter :: ARG_NAME_LEN = 32

Maximum length of argument name.

integer, public, parameter :: ARG_VALUE_LEN = FILE_PATH_LEN

Maximum length of argument value.


Abstract Interfaces

abstract interface

  • public subroutine dm_arg_version_callback()

    Callback routine that outputs the version information.

    Arguments

    None

Derived Types

type, public ::  arg_class

Public class to store and parse command-line arguments.

Type-Bound Procedures

procedure, public :: add => arg_add
procedure, public :: create => arg_create
procedure, public :: destroy => arg_destroy
generic, public :: get => get_int32, get_logical, get_real64, get_string
procedure, public :: passed => arg_passed
procedure, public :: read => arg_read