{"id":15558472,"url":"https://github.com/lukesavefrogs/jycli","last_synced_at":"2026-06-22T16:32:21.653Z","repository":{"id":222102757,"uuid":"756089443","full_name":"LukeSavefrogs/jycli","owner":"LukeSavefrogs","description":"Small Jython framework for creating standardized CLI applications with support for Python versions down to 2.1","archived":false,"fork":false,"pushed_at":"2025-11-19T17:17:10.000Z","size":63,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-21T10:27:43.397Z","etag":null,"topics":[],"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/LukeSavefrogs.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"LukeSavefrogs","patreon":"LukeSavefrogs","ko_fi":"lukesavefrogs","custom":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RN3XMAHA8FZEE\u0026source=url"]}},"created_at":"2024-02-11T23:13:48.000Z","updated_at":"2025-11-19T17:17:14.000Z","dependencies_parsed_at":"2025-01-25T18:39:45.015Z","dependency_job_id":null,"html_url":"https://github.com/LukeSavefrogs/jycli","commit_stats":null,"previous_names":["lukesavefrogs/jycli"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LukeSavefrogs/jycli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjycli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjycli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjycli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjycli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukeSavefrogs","download_url":"https://codeload.github.com/LukeSavefrogs/jycli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukeSavefrogs%2Fjycli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34657893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-02T15:34:58.086Z","updated_at":"2026-06-22T16:32:21.630Z","avatar_url":"https://github.com/LukeSavefrogs.png","language":"Python","funding_links":["https://github.com/sponsors/LukeSavefrogs","https://patreon.com/LukeSavefrogs","https://ko-fi.com/lukesavefrogs","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=RN3XMAHA8FZEE\u0026source=url"],"categories":[],"sub_categories":[],"readme":"# Jython CLI Library\n\nThe JyCLI (_Jython CLI_) package has been developed to make it easier to create script to create CLI applications using Jython.\n\n## `application.Application`\n\nThe `application.Application` class allows creating CLI applications in a standardized way.\n\n### Features\n\n- **Automatic exit status**: `1` if the return status is a falsy boolean (_both `bool` or just a falsy `int`_), `0` otherwise (_`None` is considered as success_);\n- Automatic **divider** to separate the actual script execution from all the previous boilerplate (_by default a full-width line consisting of `-` characters with the application name at the center_); can be customized.\n- Use **hooks** to customize the behavior of the application before it closes: `on_success` (_when it ends without errors_), `on_failure` (_when it fails because of an exception or falsy return code_) and `on_finish` (_always executed at the end before closing the application_).\n- Define a custom `has_failed` method if you want to customize when a specific return code should make the application fail (_for example, you may want to restrict only to numeric return values_).\n- Automatically disables colors when it detects the [`NO_COLOR` variable](https://no-color.org/) or if the console is not interactive.\n\n### Example\n\nTake the following simple application. If you execute this code you'll note that the **return code** of is set to `0` (_which means success in Bash_); if you change the `return` statement in the `MyApplication.main()` method to `return 1==0` (_basically `False`_) the RC of the application will be `1` (_which means that an error occurred in Bash_).\n\nAnother thing to take note is that **hooks** can access **local variables** defined in the `MyApplication.main()` using the `context.locals` dictionary.\n\n```python\nfrom jycli.application import Application, ApplicationContext\n\nclass MyApplication(Application):\n    \"\"\" This is a simple example of a CLI application. \"\"\"\n    title = \"My Application\"\n\n    divider = \"------------------- %(title)s -------------------\"\n\n    def main(self):\n        text = \"Hello World!\"\n        print(text)\n        \n        _time.sleep(2)\n        return 1==1\n    \n    def on_success(self, context):\n        # type: (ApplicationContext) -\u003e None\n        print(\"Success! Text printed: %s\" % context.locals.get(\"text\", None))\n\n    def on_failure(self, context):\n        # type: (ApplicationContext) -\u003e None\n        print(\"Failure!\")\n    \n    def on_finish(self, context):\n        # type: (ApplicationContext) -\u003e None\n        print(\"\\nFinish!\")\n        print(\"Context: %s\" % context)\n\n        print(\"\\n---\u003e Total execution time: %s seconds (%sh:%sm:%ss)\" % (\n            context.duration,\n            int(context.duration / 3600),\n            int(context.duration / 60 % 60),\n            int(context.duration % 60)\n        ))\n\n\napp = MyApplication()\napp.run()\n```\n\nThis code will produce the following output:\n\n```text\n------------------- My Application -------------------\nHello World!\n------------------- My Application -------------------\nSuccess! Text printed: Hello World!\n\nFinish!\nContext: ApplicationContext(duration=2.0, locals={'self': \u003c__main__.MyApplication instance at 1094034428\u003e, 'text': 'Hello World!'}, start_time=1.702979951763E9, return_value=True, end_time=1.702979953763E9, application=\u003c__main__.MyApplication instance at 1094034428\u003e)\n\n---\u003e Total execution time: 2.0 seconds (0h:0m:2s)\n```\n\n## `table` module\n\nThe `table` module exposes the `Table` class that comes in handy when creating **tables** that should render nicely (_and responsively_) in the terminal. It also provides methods for exporting the table data in **CSV** (`.to_csv()`) and **HTML** (`.to_html()`) format.\n\n### Features\n\n- Support for multiple render targets: to **terminal** (`.render()`), to **CSV** (`.to_csv()`) and to **HTML** (`.to_html()`);\n- Customize the **table width** when rendering to the terminal (_default is full terminal width_);\n- **Wrap lines** if they are too long to render on a single line or if they contains a new line (`\\n`).\n\n### Example\n\n```python\nfrom jycli.components.table import Table\n\ntable = Table(\"My beautiful table\", [\"Column1\", \"Column2\"])\ntable.add_row(\"Value1\", \"Value2\")\ntable.add_row(\"Value3\", \"Value4\")\n\nprint(table.render())\n# Output:\n#   ***********************************************************\n#                        My beautiful table\n#   ***********************************************************\n#   Column1                     | Column2\n#   --------------------------- | --------------------------\n#   Value1                      | Value2\n#   Value3                      | Value4\n\n\nprint(table.to_csv())\n# Output:\n#   Column1,Column2\n#   Value1,Value2\n#   Value3,Value4\n\nprint(table.to_html())\n# Output:\n#   \u003ctable\u003e\n#   \u003ccaption\u003eMy beautiful table\u003c/caption\u003e\n#   \u003cthead\u003e\n#   \u003ctr\u003e\n#   \u003cth\u003eColumn1\u003c/th\u003e\n#   \u003cth\u003eColumn2\u003c/th\u003e\n#   \u003c/tr\u003e\n#   \u003c/thead\u003e\n#   \u003ctbody\u003e\n#   \u003ctr\u003e\n#   \u003ctd\u003eValue1\u003c/td\u003e\n#   \u003ctd\u003eValue2\u003c/td\u003e\n#   \u003c/tr\u003e\n#   \u003ctr\u003e\n#   \u003ctd\u003eValue3\u003c/td\u003e\n#   \u003ctd\u003eValue4\u003c/td\u003e\n#   \u003c/tr\u003e\n#   \u003c/tbody\u003e\n```\n\n## `console` module\n\nThe `console` module as the name suggests allows interacting with the console terminal.\n\nFor example, you can get the terminal width and height:\n\n```python\nfrom jycli.console import Console\n\nconsole = Console()\nprint(\"%dh x %dw\" % (console.width, console.height))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukesavefrogs%2Fjycli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukesavefrogs%2Fjycli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukesavefrogs%2Fjycli/lists"}