menucraft


Namemenucraft JSON
Version 0.0.1 PyPI version JSON
download
home_page
SummaryA simple package for generating menus for cli interactive programs where user input is required.
upload_time2023-09-07 17:42:23
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords cli cli-interactive-menu menu
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cli Menu helper/utility

I got tired of using while loops over and over again to validate user inputs in simple programs that I have in school.
I wanted to focus on the core logic there rather that spend time reinventing the same looking menus. 

How it usualy goes. You have a list of menus u want to print out pretty. Usualy with numbers in front

## That would look like something like this

Example:
```bash
Available commands: 
1) menu_item 
2) menu_item
>> 
```
or 

```bash
other title
1) menu_item 2) menu_item
>> 
```
No problem if you just have one menu. But if you have multiple menus and if your user has the option to come back to slightly diffrent menu?
It's a hassle and simply put annoying. Because u need to validate input, map it either to match the string you specified
or simply use numbers.
And what if you want to use both- numbers and the actual name as user input?

## Backstory

When I was building interactive fiction game in Python I came up with a solution.
Why not create an Menu object? And have all creating(printing) and validating logic inside there?
Yo you could even add extra function calls within those elements that are not even present by them selves
in the menu. Like in interactive fictions "hint" option. 

After I was done with my game and got my hands on new interactive menu programs, like simple book store
I created and uploaded my package on pypi so that I could use it whenever I want.

## So here is my solution :) 
## Usage:
###  Initalization
```bash 
pip install menucraft
```
Takes user options as an python list like this(mandatory to be inside an list): 
```Python
from menucraft.menu import Menu 

instance_name = Menu(["option_1", "option_2"])
```

> :warning:  **Must be writen in lower case!**

### Method show(inline, title)
Method to print out options. Takes arguments: title:str, inline:bool

1. Title: available commands (default value). inline = True(default)
```Bash 
Available commands: 1) option_1 2) option_2
```
2. title="Custom title :)", inline = False
```Bash 
Custom title :)
1) option_1 
2) option_2
```

### Method index(menu_item_index)
Method to use in if statements, simply useses the list items index
Remebember: list start with number 0. so first option_1 would be index(0)
Return the element of the index.
```python 
instance_name = Menu(["option_1", "option_2"])
instance_name.show()
choice = instance_name.validator()

if choice == instance_name.index(0): #This will be choice_1
   print("do something")
else:
   print("can only be the last element") # this will be choice_2 or last element in the list
```

###  Method validator()
```python 
choice = instance_name.validator()
```
choice is the variable that will be used in if statements to compare to instance_name.index(index)

* Takes an user input can be both numbers and full word, input is not case sensitive (human error handled)
* error messages
* returns an validated user option 

### Method all()
syntax
```python 
choice = instance_name.all()
```
uses instance_name.show()
1. prints out the options
2. Returns an validated choice from the options initiliized



## TODO
- [ ] come up with better way of adding menu items. Instead of passing them as [item...]
- [ ] Make so that you can pass in functions that require to pass in user input that is validated inside there
- [ ] More customization for example to be able to change ">> " to smth else?


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "menucraft",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "Cli,cli-interactive-menu,Menu",
    "author": "",
    "author_email": "Eduards Abishevs <eduards@abishevs.dev>",
    "download_url": "https://files.pythonhosted.org/packages/d8/47/8b727de772c351c6f49a3bb73aa60b017f4250ce0e68353c330ded6d5fa6/menucraft-0.0.1.tar.gz",
    "platform": null,
    "description": "# Cli Menu helper/utility\n\nI got tired of using while loops over and over again to validate user inputs in simple programs that I have in school.\nI wanted to focus on the core logic there rather that spend time reinventing the same looking menus. \n\nHow it usualy goes. You have a list of menus u want to print out pretty. Usualy with numbers in front\n\n## That would look like something like this\n\nExample:\n```bash\nAvailable commands: \n1) menu_item \n2) menu_item\n>> \n```\nor \n\n```bash\nother title\n1) menu_item 2) menu_item\n>> \n```\nNo problem if you just have one menu. But if you have multiple menus and if your user has the option to come back to slightly diffrent menu?\nIt's a hassle and simply put annoying. Because u need to validate input, map it either to match the string you specified\nor simply use numbers.\nAnd what if you want to use both- numbers and the actual name as user input?\n\n## Backstory\n\nWhen I was building interactive fiction game in Python I came up with a solution.\nWhy not create an Menu object? And have all creating(printing) and validating logic inside there?\nYo you could even add extra function calls within those elements that are not even present by them selves\nin the menu. Like in interactive fictions \"hint\" option. \n\nAfter I was done with my game and got my hands on new interactive menu programs, like simple book store\nI created and uploaded my package on pypi so that I could use it whenever I want.\n\n## So here is my solution :) \n## Usage:\n###  Initalization\n```bash \npip install menucraft\n```\nTakes user options as an python list like this(mandatory to be inside an list): \n```Python\nfrom menucraft.menu import Menu \n\ninstance_name = Menu([\"option_1\", \"option_2\"])\n```\n\n> :warning:  **Must be writen in lower case!**\n\n### Method show(inline, title)\nMethod to print out options. Takes arguments: title:str, inline:bool\n\n1. Title: available commands (default value). inline = True(default)\n```Bash \nAvailable commands: 1) option_1 2) option_2\n```\n2. title=\"Custom title :)\", inline = False\n```Bash \nCustom title :)\n1) option_1 \n2) option_2\n```\n\n### Method index(menu_item_index)\nMethod to use in if statements, simply useses the list items index\nRemebember: list start with number 0. so first option_1 would be index(0)\nReturn the element of the index.\n```python \ninstance_name = Menu([\"option_1\", \"option_2\"])\ninstance_name.show()\nchoice = instance_name.validator()\n\nif choice == instance_name.index(0): #This will be choice_1\n   print(\"do something\")\nelse:\n   print(\"can only be the last element\") # this will be choice_2 or last element in the list\n```\n\n###  Method validator()\n```python \nchoice = instance_name.validator()\n```\nchoice is the variable that will be used in if statements to compare to instance_name.index(index)\n\n* Takes an user input can be both numbers and full word, input is not case sensitive (human error handled)\n* error messages\n* returns an validated user option \n\n### Method all()\nsyntax\n```python \nchoice = instance_name.all()\n```\nuses instance_name.show()\n1. prints out the options\n2. Returns an validated choice from the options initiliized\n\n\n\n## TODO\n- [ ] come up with better way of adding menu items. Instead of passing them as [item...]\n- [ ] Make so that you can pass in functions that require to pass in user input that is validated inside there\n- [ ] More customization for example to be able to change \">> \" to smth else?\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A simple package for generating menus for cli interactive programs where user input is required.",
    "version": "0.0.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/Abishevs/MenuCraft/issues",
        "Homepage": "https://github.com/Abishevs/MenuCraft"
    },
    "split_keywords": [
        "cli",
        "cli-interactive-menu",
        "menu"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a172a749c3d83b0737bfbd2b1a0312dc2ca5800b18a49e948e1cb38eb4b6e96",
                "md5": "b054f3b478e85186897567dd89c2b72a",
                "sha256": "c7ea4c91c981e6c96a09ded706d105e7bde7bac9a10adcb7160380249bbee96b"
            },
            "downloads": -1,
            "filename": "menucraft-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b054f3b478e85186897567dd89c2b72a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5034,
            "upload_time": "2023-09-07T17:42:22",
            "upload_time_iso_8601": "2023-09-07T17:42:22.482361Z",
            "url": "https://files.pythonhosted.org/packages/0a/17/2a749c3d83b0737bfbd2b1a0312dc2ca5800b18a49e948e1cb38eb4b6e96/menucraft-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8478b727de772c351c6f49a3bb73aa60b017f4250ce0e68353c330ded6d5fa6",
                "md5": "3469d3f764dddaa70c50812446640082",
                "sha256": "d21ba2dbfd050f37c7e4a0ba01d70b6111c5f49d947daccb14fecdb72a55ad64"
            },
            "downloads": -1,
            "filename": "menucraft-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3469d3f764dddaa70c50812446640082",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4732,
            "upload_time": "2023-09-07T17:42:23",
            "upload_time_iso_8601": "2023-09-07T17:42:23.783200Z",
            "url": "https://files.pythonhosted.org/packages/d8/47/8b727de772c351c6f49a3bb73aa60b017f4250ce0e68353c330ded6d5fa6/menucraft-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-07 17:42:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Abishevs",
    "github_project": "MenuCraft",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "menucraft"
}
        
Elapsed time: 0.11045s