Skip to content
Stefano Zaghi edited this page Mar 24, 2016 · 7 revisions

To start using FLAP and declaring your CLI, you must import its main module:

use flap

This module exposes only one object, namely command_line_interface.

To start using FLAP you must obviously define a CLI object:

type(command_line_interface):: cli

Now that you have your CLI declared you can start using it. The API to handle it follows.

API

The main CLI object, that is the only one you must know, is a command_line_interface object. It has all attributes necessary for its internal operations defined as private, thus you should not care about them. The interaction with the library is safely performed by means of only the public methods available. However, some useful attributes are public in order to facilitates some minor tasks (e.g. printing authors list).

Essentially, for building up and using a minimal CLI you should follow the 4 steps:

1. declare a CLI variable:
type(command_line_interface):: cli
2. add one or more CLA definition to the CLI:
call cli%add(switch='-o', help='Output file name', def='myfile.md', error=error)
3. parse the actually passed command line arguments (optional):
call cli%parse(error=error)

This step is optional, namely the explicit call to parse method is optional: the first time you will call the get method the parsed status of the CLI is checked and, if necessary, the parse method is automatically called inside the get method.

4. get parsed values and storing into user-defined variables:
call cli%get(switch='-o', val=OutputFilename, error=error)

OutputFilename and error being previously defined variables.

CLI Methods API

Assuming that you have stated:

USE Data_Type_Command_Line_Interface
type(Type_Command_Line_Interface):: CLI

the following are the complete APIs of all public CLI methods

Public Attributes

character(len=:), public, allocatable :: progname      !< Program name.
character(len=:), public, allocatable :: version       !< Program version.
character(len=:), public, allocatable :: description   !< Detailed description.
character(len=:), public, allocatable :: license       !< License description.
character(len=:), public, allocatable :: authors       !< Authors list.
character(len=:), public, allocatable :: epilog        !< Epilog message.
character(len=:), public, allocatable :: m_exclude     !< Mutually exclude other CLA(s group).
character(len=:), public, allocatable :: error_message !< Meaningful error message.
integer(I4P),     public              :: error         !< Error traping flag.
Clone this wiki locally