chancleta


Namechancleta JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryPython library for creating Command Line Interfaces via configuration files. Supports .toml, .json, .yaml and .xml (for the brave ones)
upload_time2024-11-14 11:34:17
maintainerNone
docs_urlNone
authorkaliv0
requires_python<4.0,>=3.12
licenseLICENSE
keywords command line interface cli starter kit toml json yaml xml
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="https://github.com/kaliv0/chancleta/blob/main/assets/chancleta.gif?raw=true" width="250" alt="Chancleta Samurai">
</p>

# chancleta

![Python 3.x](https://img.shields.io/badge/python-3.12-blue?style=flat-square&logo=Python&logoColor=white)
[![PyPI](https://img.shields.io/pypi/v/chancleta.svg)](https://pypi.org/project/chancleta/)
[![Downloads](https://static.pepy.tech/badge/chancleta)](https://pepy.tech/projects/chancleta)

<br>Python library for creating <b>command line interfaces</b> in a composable way via configuration files.
<br> Supports <i>.toml</i>, <i>.json</i>, <i>.yaml</i>. and (if you'd like to be more adventurous) <i>.xml</i>.

---------------------------
### How to use
- Describe configurations in a chancleta.toml file. 
<br>(File format could vary between .toml, .json, .yaml and .xml as long as the name remains the same.)
<br>Add mandatory <i>'meta'</i> data with general information about your program

```toml
[meta]
src = "testoo.util.commands"
prog = "foo"
version = "0.1.0"
description = "Test my new flip flops"
usage = "Take that jive Jack, put it in your pocket 'til I get back"
```
<b>'src'</b> points to the directory where the corresponding python functions are to be found and called with arguments read from the terminal
- Configure subcommands as separate tables (objects if you're using JSON)

```toml
[yes]
description = "Simple yes function"
argument = { name = "text", help = "Some dummy text" }
option = { name = "should-repeat", short = "r", flag = "True", help = "should repeat text 5 times" }
help = "yes func"
function = "yes"
```
<b>function</b> shows the name of the python function to be called
- If you have multiple arguments/options - put them as inline tables inside arrays
```toml
[echo]
arguments = [
    { name = "text", help = "Some dummy text" },
    { name = "mark", type = "str", help = "Final mark" },
]
options = [
    { name = "other-text", short = "o", default = "Panda", dest = "other", help = "Some other dummy text" },
    { name = "delimiter", default = ", ", help = "use DELIM instead of TAB for field delimiter" },
    { name = "num", default = 42, type = "int", help = "some random number to make things pretty" }
]
function = "echo"
```
<i>chancleta</i> supports advanced features such as <i>choices</i>, <i>nargs</i>, <i>dest</i> (for options), <i>type</i> validation
```toml
[maybe]
argument = { name = "number", type = "int", choices = [3, 5, 8], help = "Some meaningless number" }
option = { name = "other-number", type = "int", nargs = "*", choices = [1, 2], dest = "other", help = "Other marvelous number" }
function = "maybe"
```
- For boolean flags you could use
 ```toml
options = [
    { name = "should-log", flag = "False", default = true },
    { name = "should-repeat", flag = "True"}
]
```
which is equivalent to
```
action="store_false"...
action="store_true"...
```
- If no <i>short</i> name is given for an option, the first letter of the full name is used
---------------------------

- Inside your program import the <i>Chancleta</i> object, pass a path to the directory where your config file lives and call the <i>parse</i> method
```python
from chancleta import Chancleta

def main():
    Chancleta("./testoo/config").parse()
```
If no path is given chancleta will try to find the config file inside the root directory of your project

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "chancleta",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": "command line interface, cli starter kit, toml, json, yaml, xml",
    "author": "kaliv0",
    "author_email": "kaloyan.ivanov88@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/2e/3201c2fcb839ff7696a10051282229f04cf1c79fd2e24b5f1c0323fb444d/chancleta-1.0.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"https://github.com/kaliv0/chancleta/blob/main/assets/chancleta.gif?raw=true\" width=\"250\" alt=\"Chancleta Samurai\">\n</p>\n\n# chancleta\n\n![Python 3.x](https://img.shields.io/badge/python-3.12-blue?style=flat-square&logo=Python&logoColor=white)\n[![PyPI](https://img.shields.io/pypi/v/chancleta.svg)](https://pypi.org/project/chancleta/)\n[![Downloads](https://static.pepy.tech/badge/chancleta)](https://pepy.tech/projects/chancleta)\n\n<br>Python library for creating <b>command line interfaces</b> in a composable way via configuration files.\n<br> Supports <i>.toml</i>, <i>.json</i>, <i>.yaml</i>. and (if you'd like to be more adventurous) <i>.xml</i>.\n\n---------------------------\n### How to use\n- Describe configurations in a chancleta.toml file. \n<br>(File format could vary between .toml, .json, .yaml and .xml as long as the name remains the same.)\n<br>Add mandatory <i>'meta'</i> data with general information about your program\n\n```toml\n[meta]\nsrc = \"testoo.util.commands\"\nprog = \"foo\"\nversion = \"0.1.0\"\ndescription = \"Test my new flip flops\"\nusage = \"Take that jive Jack, put it in your pocket 'til I get back\"\n```\n<b>'src'</b> points to the directory where the corresponding python functions are to be found and called with arguments read from the terminal\n- Configure subcommands as separate tables (objects if you're using JSON)\n\n```toml\n[yes]\ndescription = \"Simple yes function\"\nargument = { name = \"text\", help = \"Some dummy text\" }\noption = { name = \"should-repeat\", short = \"r\", flag = \"True\", help = \"should repeat text 5 times\" }\nhelp = \"yes func\"\nfunction = \"yes\"\n```\n<b>function</b> shows the name of the python function to be called\n- If you have multiple arguments/options - put them as inline tables inside arrays\n```toml\n[echo]\narguments = [\n    { name = \"text\", help = \"Some dummy text\" },\n    { name = \"mark\", type = \"str\", help = \"Final mark\" },\n]\noptions = [\n    { name = \"other-text\", short = \"o\", default = \"Panda\", dest = \"other\", help = \"Some other dummy text\" },\n    { name = \"delimiter\", default = \", \", help = \"use DELIM instead of TAB for field delimiter\" },\n    { name = \"num\", default = 42, type = \"int\", help = \"some random number to make things pretty\" }\n]\nfunction = \"echo\"\n```\n<i>chancleta</i> supports advanced features such as <i>choices</i>, <i>nargs</i>, <i>dest</i> (for options), <i>type</i> validation\n```toml\n[maybe]\nargument = { name = \"number\", type = \"int\", choices = [3, 5, 8], help = \"Some meaningless number\" }\noption = { name = \"other-number\", type = \"int\", nargs = \"*\", choices = [1, 2], dest = \"other\", help = \"Other marvelous number\" }\nfunction = \"maybe\"\n```\n- For boolean flags you could use\n ```toml\noptions = [\n    { name = \"should-log\", flag = \"False\", default = true },\n    { name = \"should-repeat\", flag = \"True\"}\n]\n```\nwhich is equivalent to\n```\naction=\"store_false\"...\naction=\"store_true\"...\n```\n- If no <i>short</i> name is given for an option, the first letter of the full name is used\n---------------------------\n\n- Inside your program import the <i>Chancleta</i> object, pass a path to the directory where your config file lives and call the <i>parse</i> method\n```python\nfrom chancleta import Chancleta\n\ndef main():\n    Chancleta(\"./testoo/config\").parse()\n```\nIf no path is given chancleta will try to find the config file inside the root directory of your project\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "Python library for creating Command Line Interfaces via configuration files. Supports .toml, .json, .yaml and .xml (for the brave ones)",
    "version": "1.0.2",
    "project_urls": {
        "repository": "https://github.com/kaliv0/chancleta.git"
    },
    "split_keywords": [
        "command line interface",
        " cli starter kit",
        " toml",
        " json",
        " yaml",
        " xml"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a02224a2b433674d30bb7bbd78ca1df476af6f7ad79cf5d36aa3a84e07b28892",
                "md5": "6c3786980ba6d0cb3602a0ef20f688a7",
                "sha256": "ed8b70177f56b8b85103682cd53ea2d432556a7319ac2a859339374bc181950a"
            },
            "downloads": -1,
            "filename": "chancleta-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c3786980ba6d0cb3602a0ef20f688a7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 5456,
            "upload_time": "2024-11-14T11:34:15",
            "upload_time_iso_8601": "2024-11-14T11:34:15.734913Z",
            "url": "https://files.pythonhosted.org/packages/a0/22/24a2b433674d30bb7bbd78ca1df476af6f7ad79cf5d36aa3a84e07b28892/chancleta-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d2e3201c2fcb839ff7696a10051282229f04cf1c79fd2e24b5f1c0323fb444d",
                "md5": "9443bd8b5b90572b33f497e0d478b98a",
                "sha256": "97a9fc2be8fc3beca0582ca8cd69e9bdfa5a7dbf57aafc14cb73fcdcf42b2798"
            },
            "downloads": -1,
            "filename": "chancleta-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9443bd8b5b90572b33f497e0d478b98a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 4910,
            "upload_time": "2024-11-14T11:34:17",
            "upload_time_iso_8601": "2024-11-14T11:34:17.382715Z",
            "url": "https://files.pythonhosted.org/packages/9d/2e/3201c2fcb839ff7696a10051282229f04cf1c79fd2e24b5f1c0323fb444d/chancleta-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 11:34:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kaliv0",
    "github_project": "chancleta",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "chancleta"
}
        
Elapsed time: 0.50034s