{"id":27320129,"url":"https://github.com/rucub100/clifw","last_synced_at":"2025-04-12T09:13:04.305Z","repository":{"id":49103239,"uuid":"221070552","full_name":"rucub100/clifw","owner":"rucub100","description":"Yet another CLI framework for parsing command line arguments passed to programs. The API also allows you to build an interactive shell.","archived":false,"fork":false,"pushed_at":"2024-10-03T18:44:04.000Z","size":58,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T09:13:02.678Z","etag":null,"topics":["argument-parser","cli-parser","fluent-api","interactive-shell","shell-prompt","test-driven-development"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rucub100.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-11T21:09:36.000Z","updated_at":"2021-06-28T21:25:15.000Z","dependencies_parsed_at":"2025-04-12T09:13:03.976Z","dependency_job_id":null,"html_url":"https://github.com/rucub100/clifw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rucub100%2Fclifw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rucub100%2Fclifw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rucub100%2Fclifw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rucub100%2Fclifw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rucub100","download_url":"https://codeload.github.com/rucub100/clifw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543842,"owners_count":21121838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-parser","cli-parser","fluent-api","interactive-shell","shell-prompt","test-driven-development"],"created_at":"2025-04-12T09:13:01.953Z","updated_at":"2025-04-12T09:13:04.296Z","avatar_url":"https://github.com/rucub100.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clifw\nYet another ultra lightweight CLI framework for parsing command line arguments passed to programs.\u003cbr\u003e\nThe API also allows you to build an interactive shell.\n\n## Example\nThe main public API `CLI` allows you to build a schema for the expected arguments.\u003cbr\u003e\nThis is a convenient solution that offers a modern, descriptive and fluent manner.\n\n```java\npublic static void main(String[] args) {\n    CLI cli = CLI.setArgs(args) // args = new String[] { \"-a\" }\n        .addOpt(Opt\n            .useChar('a')\n            .description(\"this is a short test option\")\n            .build())\n        .build();\n    ...\n}\n```\n\nOnce you've defined the schema, call the `run` method and let the framework do it's job.\n\n```java\ntry {\n    cli.run();\n    ...\n} catch(Exception e) {\n    System.err.println(e.getMessage());\n}\n```\n\nThe last step is to process the result `cli.getResult()` in your own business code.\u003cbr\u003e\nFor an example of an interactive shell, read the [shell](docs/SHELL.md) documentation.\n\n## General Design\n\nThe main building block is the schema which consists of different other sub building blocks and glue components.\n\n### Schema\n\n| Name                  | Pattern                 | Examples                                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                         |\n|-----------------------|-------------------------|------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ***Options***         | `[-\u003co\u003e\\|--\u003coption\u003e]...`     | `-r`\u003cbr\u003e`--recursive`\u003cbr\u003e`-o=filename`\u003cbr\u003e`-i name` | This schema allows to define an arbitrary sequence of options. An option is either a single character with a preceding `-` or any word with a preceding `--`. An optional value can be assigned, either in the mathematical notation with the `=` sign or simply separated by a *space*. Obviously, further restrictions on the value must be made, for example it must not start with a dash or contain spaces. |\n| ***Arguments***       | `[\u003carg\u003e]...`              | `1 2 3`\u003cbr\u003e`\"My Name\"`                         | Numbers or words can be used as arguments. If a single argument contains spaces, it must be enclosed in quotation marks. |\n| ***Options and arguments*** | `[-\u003co\u003e\\|--\u003coption\u003e]... [\u003carg\u003e]...` | `-c 3 output.txt`                   | The order is important here, the first argument may only come after the last option including its value, if any. |\n| ***Commands***        | `\u003ccommand\u003e [-\u003co\u003e\\|--\u003coption\u003e]... [\u003carg\u003e]...` | `checkout -b development`         | Note that at most one command can be passed as an argument per call. However, any number of different commands can of course be defined in the API. |\n| ***Shell***           |                         |                                                | Behaves like if you put the *Commands* scheme in a loop. Before entering the interactive shell, the *Options and arguments* schema applies. |\n\nThe `setArgs` and `useShell` methods initiate the declarative definition of the schema. In the first method, a schema can be passed as an optional argument, the default value corresponds to \"*Options*\". However, a builder object is returned, which is also implemented as a fluent interface. See [API](docs/API.md) section for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frucub100%2Fclifw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frucub100%2Fclifw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frucub100%2Fclifw/lists"}