LCOV - code coverage report
Current view: top level - src - mo_smi_cli.f90 (source / functions) Hit Total Coverage
Test: SMI coverage Lines: 9 9 100.0 %
Date: 2024-04-30 09:16:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !> \file    mo_smi_cli.f90
       2             : !> \brief   \copybrief mo_smi_cli
       3             : !> \details \copydetails mo_smi_cli
       4             : 
       5             : !> \brief   Module to parse command line arguments of SMI.
       6             : !> \version 0.1
       7             : !> \authors Sebastian Mueller
       8             : !> \date    Oct 2021
       9             : !> \details A simple parser for command line arguments for smi.
      10             : !!          You can pass the path to the config namelist (main.dat by default)
      11             : !!
      12             : !!          You can also pass the CWD as plain last argument and get a help or version text.
      13             : !!
      14             : !!          \code{.sh}
      15             : !!          smi -h
      16             : !!          smi -v
      17             : !!          \endcode
      18             : !> \copyright Copyright 2005-\today, the CHS Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
      19             : !! SMI is released under the LGPLv3+ license \license_note
      20             : module mo_smi_cli
      21             :   implicit none
      22             : 
      23             :   private
      24             : 
      25             :   public :: parse_command_line
      26             : 
      27             : contains
      28             : 
      29             :   !> \brief parse the given command line arguments.
      30           6 :   subroutine parse_command_line()
      31             :     use mo_cli, only: cli_parser
      32             :     use mo_smi_info, only: version, file_namelist
      33             :     use mo_os, only: change_dir
      34             : 
      35             :     implicit none
      36             : 
      37           6 :     type(cli_parser) :: parser
      38             : 
      39             :     parser = cli_parser( &
      40             :       description="The Soil Moisture Index - SMI program", &
      41             :       add_version_option=.true., &
      42           6 :       version=version)
      43             : 
      44             :     call parser%add_option( &
      45             :       name="cwd", &
      46             :       blank=.true., &
      47           6 :       help="The desired working directory (optional).")
      48             : 
      49             :     call parser%add_option( &
      50             :       name="nml", &
      51             :       s_name="n", &
      52             :       has_value=.true., &
      53             :       value_name="path", &
      54             :       default="main.dat", &
      55           6 :       help="The SMI configuration namelist.")
      56             : 
      57             :     ! parse given command line arguments
      58           6 :     call parser%parse()
      59             : 
      60             :     ! change working directory first
      61           6 :     if (parser%option_was_read("cwd")) call change_dir(parser%option_value("cwd"))
      62             : 
      63             :     ! set nml file path
      64           6 :     file_namelist = parser%option_value("nml")
      65             : 
      66          30 :   end subroutine parse_command_line
      67             : 
      68             : end module mo_smi_cli

Generated by: LCOV version 1.16