{"id":17415775,"url":"https://github.com/michalwa/py-cliffs","last_synced_at":"2025-04-02T23:25:17.762Z","repository":{"id":140980681,"uuid":"266572348","full_name":"michalwa/py-cliffs","owner":"michalwa","description":"Command Line Interface Utility","archived":false,"fork":false,"pushed_at":"2020-12-13T20:39:37.000Z","size":371,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T13:42:20.050Z","etag":null,"topics":["cli","command-line","parser","syntax","utility"],"latest_commit_sha":null,"homepage":"","language":"Python","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/michalwa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2020-05-24T15:43:35.000Z","updated_at":"2020-12-13T20:39:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5f98df9-484f-4776-849c-d9953945fc03","html_url":"https://github.com/michalwa/py-cliffs","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/michalwa%2Fpy-cliffs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalwa%2Fpy-cliffs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalwa%2Fpy-cliffs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalwa%2Fpy-cliffs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michalwa","download_url":"https://codeload.github.com/michalwa/py-cliffs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246907646,"owners_count":20853129,"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":["cli","command-line","parser","syntax","utility"],"created_at":"2024-10-17T01:45:45.696Z","updated_at":"2025-04-02T23:25:17.744Z","avatar_url":"https://github.com/michalwa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cliffs\nThis is an implementation of [Clifford](https://github.com/michalwa/Clifford)\n(originally written in Java) for Python 3.9.\nAlthough this implementation has much more functionality,\nit's still compliant with the original concept.\n\n**Clifford** is a command parsing utility useful for creating internal\ncommand line interfaces for your applications. Its syntax specification method\nallows command definitions and usage help to be united with a single syntax.\nThis way usage specification can be directly used to generate command parsers.\n\nThe advantage of this method is that it makes it possible to avoid long chained\nmethod calls for constructing command parsers, as it is usually done in libraries.\n\n## Syntax\n**Clifford** uses a rather intuitive syntax to specify the syntax of commands:\n- `literals` specify required terms that the command call must contain\n  in order to match the specification\n- `\u003cparameters\u003e` accept a single token in the command call and store its value\n  for processing by the command handler; parameters can also specify types\n  (`\u003cparam: type\u003e`) which their values will be validated for and parsed into\n- `\u003cvarargs*\u003e` will collect any remaining tokens and store them as a list\n- `\u003ctails...\u003e` will collect any remaining tokens after all previous elements\n  as raw text\n- `(variant|groups)` encapsulate sequences of elements and accept only one of\n  those sequences (index of the present sequence is stored for processing by the handler)\n- `[optional sequences]` may or may not be present in the command call\n  (boolean indicating presence is stored for processing by the handler)\n- `{unordered groups}` whose elements can be present in an arbitrary order\n\n## Example\nTo demonstrate the concept of how **Clifford** works, consider this simple command syntax\nspecification:\n\n    set [loud] alarm at \u003chour: int\u003e [am|pm] [every \u003cdays\u003e] [saying \u003cmessage\u003e]\n\nSuch defined syntax accepts the following command calls:\n\n    set alarm at 9 am\n        opts = [False, True, False, False]\n        vars = [0]\n        params = {'hour': '9'}\n\n    set loud alarm at 7 every monday\n        opts = [True, False, True, False]\n        params = {'hour': 7, 'days': 'monday'}\n\n    set alarm at 2 pm every monday saying 'Hello, world!'\n        opts = [False, True, True, True]\n        vars = [1]\n        params = {'hour': 2, 'days': 'monday', 'message': 'Hello, world!'}\n\nAnd will reject the following with appropriate info:\n\n    set alarm          (Expected literal 'at')\n    set loud alarm at  (Expected argument for parameter \u003chour\u003e)\n    set alarm at pm    (Argument 'pm' for parameter \u003chour\u003e does not match type int)\n    ...\n\nFor more syntax features and implementation details check out the [example](example.py).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalwa%2Fpy-cliffs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichalwa%2Fpy-cliffs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalwa%2Fpy-cliffs/lists"}