{"id":18854414,"url":"https://github.com/urbanjost/m_cli","last_synced_at":"2026-01-27T05:03:16.333Z","repository":{"id":117557870,"uuid":"233769103","full_name":"urbanjost/M_CLI","owner":"urbanjost","description":"Unix-like command line parsing -- prototype style converts command line to a NAMELIST group","archived":false,"fork":false,"pushed_at":"2023-07-21T01:59:31.000Z","size":2028,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-23T05:13:52.291Z","etag":null,"topics":["argument","command","command-line","commandline-interface","fortran","fortran-package-manager","fpm","namelist","parsing"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urbanjost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-14T06:08:07.000Z","updated_at":"2024-05-31T16:26:47.000Z","dependencies_parsed_at":"2023-09-24T12:11:10.050Z","dependency_job_id":null,"html_url":"https://github.com/urbanjost/M_CLI","commit_stats":{"total_commits":76,"total_committers":2,"mean_commits":38.0,"dds":"0.013157894736842146","last_synced_commit":"ffd9fee2b70e1e22e9fc62d99dc63e4a631d6808"},"previous_names":[],"tags_count":1,"template":true,"template_full_name":null,"purl":"pkg:github/urbanjost/M_CLI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_CLI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_CLI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_CLI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_CLI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urbanjost","download_url":"https://codeload.github.com/urbanjost/M_CLI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urbanjost%2FM_CLI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28803642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argument","command","command-line","commandline-interface","fortran","fortran-package-manager","fpm","namelist","parsing"],"created_at":"2024-11-08T03:48:10.387Z","updated_at":"2026-01-27T05:03:16.302Z","avatar_url":"https://github.com/urbanjost.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# M_CLI.f90 and associated files\n\n![parse](docs/images/parse.png)\n\n## Name\n\n### M_CLI - parse Unix-like command line arguments from Fortran\n\n## Description\n\n   M_CLI(3f) is a Fortran module that will crack the command line when\n   given a NAMELIST and a prototype string that looks very much like an\n   invocation of the program. Using the NAMELIST group has the benefit\n   that there is no requirement to convert the strings to their required\n   types or to duplicate the type declarations.\n\n## Download\n   ```bash\n       git clone https://github.com/urbanjost/M_CLI.git\n       cd M_CLI/src\n       # change Makefile if not using one of the listed compilers\n     \n       # for gfortran\n       make clean\n       make F90=gfortran gfortran\n     \n       # for ifort\n       make clean\n       make F90=ifort ifort\n\n       # for nvfortran\n       make clean\n       make F90=nvfortran nvfortran\n   ```\n   This will compile the M_CLI module and build all the example programs.\n\n## Supports FPM ![fpm](docs/images/fpm_logo.gif)\n(registered at the [fpm(1) registry](https://github.com/fortran-lang/fpm-registry) )\n\n   Alternatively, download the github repository and build it with \n   fpm ( as described at [Fortran Package Manager](https://github.com/fortran-lang/fpm) )\n   \n   ```bash\n        git clone https://github.com/urbanjost/M_CLI.git\n        cd M_CLI\n        fpm test\n   ```\n   \n   or just list it as a dependency in your fpm.toml project file.\n   \n```toml\n        [dependencies]\n        M_CLI        = { git = \"https://github.com/urbanjost/M_CLI.git\" }\n```\n\n## Functional Specification\n\n**This is how the interface works --**\n   \n* Basically you define a NAMELIST group called ARGS that has the names of all your command line arguments.\n* Next, pass in a string that looks like the command you would use to execute the program with all values specified.\n* you read the output as the NAMELIST group ARGS with a fixed block of code (that could be in an INCLUDE file)\n* Now call a routine to handle errors and help-related text\n   \nNow all the values in the NAMELIST should be updated using values from the\ncommand line and ready to use.\n\n## Documentation   ![docs](docs/images/docs.gif)\nThere are several styles possible for defining the NAMELIST group as well as\noptions on whether to do the parsing in the main program or in a contained procedure.\nThese demo programs provide templates for the most common usage:\n   \n- [demo1](example/demo1.f90) full usage \n- [demo2](example/demo2.f90) shows putting everything including **help** and **version** information into a contained procedure.\n- [demo3](example/demo3.f90) example of **basic** use \n- [demo4](example/demo4.f90) using  **COMPLEX** values!\n- [demo5](example/demo5.f90) demo2 with added example code for **interactively editing the NAMELIST group**\n- [demo6](example/demo6.f90) a more complex example showing how to create a command with subcommands\n- [demo7](example/demo7.f90) problems with CHARACTER arrays and quotes\n\n### man-pages\n   \n- [M_CLI](https://urbanjost.github.io/M_CLI/M_CLI.3m_cli.html)  -- An overview of the M_CLI module\n\n- [commandline](https://urbanjost.github.io/M_CLI/commandline.3m_cli.html)  -- parses the command line options\n   \n- [check_commandline](https://urbanjost.github.io/M_CLI/check_commandline.3m_cli.html)  -- convenience\n  routine for checking status of READ of NAMELIST group\n\n- [print_dictionary](https://urbanjost.github.io/M_CLI/print_dictionary.3m_cli.html)  -- print the dictionary\n  of command line keywords and values (typically not directly by a user, as automatically called when\n  --usage option is supplied).\n\n- [specified](https://urbanjost.github.io/M_CLI/specified.3m_cli.html)  -- detect if a keyword was specified on the command line\n\n- [BOOK_M_CLI](https://urbanjost.github.io/M_CLI/BOOK_M_CLI.html) -- All man-pages consolidated using JavaScript\n\n### doxygen\n\n- [doxygen(1) output](https://urbanjost.github.io/M_CLI/doxygen_out/html/index.html).\n\n## Example Program\n   \nThis short program defines a command that can be called like\n   \n```bash\n   ./show -x 10 -y -20 --point 10,20,30 --title 'plot of stuff' *.in\n   ./show -x 10 -y -20 --point 10,20,30 --title 'plot of stuff' *.in\n   ./show -z 300\n   ./show *.in\n   ./show --usage\n   ./show --help\n   ./show --version\n```\n\n```fortran\n   program show\n   use M_CLI, only : commandline, check_commandline, files=\u003eunnamed\n   implicit none\n   integer :: i\n   \n   !! DEFINE NAMELIST\n   real               :: x, y, z             ; namelist /args/ x,y,z\n   real               :: point(3)            ; namelist /args/ point\n   character(len=80)  :: title               ; namelist /args/ title\n   logical            :: l                   ; namelist /args/ l\n   \n   !! DEFINE COMMAND\n   character(len=*),parameter :: cmd= \u0026\n      '-x 1 -y 2.0 -z 3.5e0 --point -1,-2,-3 --title \"my title\" -l F '\n   \n   !! THIS BLOCK DOES THE COMMAND LINE PARSING AND SHOULD NOT HAVE TO CHANGE\n      COMMANDLIN : block\n         character(len=255)           :: message\n         character(len=:),allocatable :: readme\n         integer                      :: ios\n         readme=commandline(cmd)\n         read(readme,nml=args,iostat=ios,iomsg=message) !! UPDATE NAMELIST VARIABLES\n         call check_commandline(ios,message)     !! HANDLE ERRORS FROM NAMELIST READ AND --usage\n      endblock COMMANDLIN\n   \n   !! USE THE VALUES IN YOUR PROGRAM.\n      write(*,nml=args)\n   \n   !! OPTIONAL UNNAMED VALUES FROM COMMAND LINE\n      if(size(files).gt.0)then\n         write(*,'(a)')'files:'\n         write(*,'(i6.6,3a)')(i,'[',files(i),']',i=1,size(files))\n      endif\n   \n   end program show\n```\n\n## Feedback\n   \n   Please provide feedback on the\n   [wiki](https://github.com/urbanjost/M_CLI/wiki) or in the\n   [__issues__](https://github.com/urbanjost/M_CLI/issues)\n   section or star the repository if you use the module (or let me know\n   why not and let others know what you did use!).\n\n-------\n\n## Other things to do with [NAMELIST](https://urbanjost.github.io/M_CLI/index.html)\n\n   click on the link for some unusual things to do with NAMELIST,\n   Capture and Replay unit testing, exposing variables for interactive\n   editing ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furbanjost%2Fm_cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furbanjost%2Fm_cli/lists"}