# Smile Arguments
## Version 1.1.2
- Improving
- Clean up
## Why SmileArgs
It is a modern args catching with python3 and OOP structure and implementation.
## Optional
Some parameters will clarify more, when instance starting
```
smile = SmileArgs(isAllowedNoValue= False, isDuplicated= False, console= True, debug= False)
```
- allowNoValue: bool= False | True
- No require value on args
- -c command does not need any assign value (Ex: python test.py -c)
- duplicated: bool= False | True
- Allowing a user types many times of any command on args (Ex: python test.py -b -b -b)
- Will execute 3 times of the command "-b" regarding to the above example
- console: bool= False | True
- A method will print error when the system catches and throw a particular error
- debug bool= False | True
- This property will track any prompt while working
## catchCommand()
- after executed run() method, it allows us to get catch command list
- show all cli command that matched to the added command
- return list
## getCommand()
- show all added commands
- return list
## run()
- find and match command via cli
- Ex: python test.py -a=Miss -b=Mom
## show()
- display all added commands
- if found commands, it will display all cough commands
## Example 1
Create a test.py
```
from SmileArgs import SmileArgs
smile = SmileArgs(console= True, debug= True)
# add command to list
smile.addCommand('a', 'alphabet', 'show alphabet')
smile.addCommand('b', 'baby', 'miss mom by her baby')
smile.addCommand('m', 'miss', 'miss mom everyday')
# catch cli command
print(f'\nFound commands via cli')
smile.run()
# show
smile.show()
```
On terminal try with this
```
$ python3.10 test.py -a -ab -a --miss=mom
```
<img width="853" alt="test-smileargs" src="https://github.com/sitthykun/smileargs/assets/227092/9855c13c-7400-4d2c-94ff-7c0508b7981a">
# Example 2
create a testclass.py
```
from SmileArgs import SmileArgs
class TestClass:
def __init__(self):
"""
"""
# private
self.__smile = SmileArgs()
self.__load()
def __load(self) -> None:
"""
"""
self.__smile.addCommand('a', 'alphabet', 'show alphabet')
self.__smile.addCommand('b', 'barbie', 'Wow, movies')
self.__smile.addCommand('m', 'miss', 'miss mom everyday')
def checkCLI(self) -> None:
"""
"""
self.__smile.run()
def executeCLICommand(self) -> None:
"""
"""
#
self.checkCLI()
#
for s in self.__smile.catchCommand():
print(f'{f.cmdShort or f.cmdLong} \t\t{f.value}')
testClass = TestClass()
testClass.executeCLICommand()
```
## cli
```
$ python3.10 testclass.py -a -ab -a --miss=mom
```
it will catch '-a' as a short command, and '--miss' as a long command;
then use match or if statement to control those states.
It is available on **PyPi** store via https://pypi.org/project/SmileArgs/ \
To Support my work, please donate me via <a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/sitthykun"><img src="https://cdn.buymeacoffee.com/buttons/bmc-new-btn-logo.svg" alt="Buy me a Pizza"><span style="margin-left:5px;font-size:28px !important;">Buy me a Coffee</span></a>
Raw data
{
"_id": null,
"home_page": "https://github.com/sitthykun/smileargs",
"name": "SmileArgs",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "argument,args,cli controller",
"author": "Sitthykun LY",
"author_email": "ly.sitthykun@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/31/83/bd857cc23973a97193979898bc337c4217930cc4a1c3f3f74bbf70e9e19e/SmileArgs-1.1.2.tar.gz",
"platform": "All",
"description": "\n# Smile Arguments\n## Version 1.1.2\n- Improving\n- Clean up\n## Why SmileArgs\nIt is a modern args catching with python3 and OOP structure and implementation.\n## Optional\nSome parameters will clarify more, when instance starting\n```\nsmile = SmileArgs(isAllowedNoValue= False, isDuplicated= False, console= True, debug= False)\n```\n- allowNoValue: bool= False | True\n - No require value on args \n - -c command does not need any assign value (Ex: python test.py -c)\n- duplicated: bool= False | True\n - Allowing a user types many times of any command on args (Ex: python test.py -b -b -b)\n - Will execute 3 times of the command \"-b\" regarding to the above example\n- console: bool= False | True\n - A method will print error when the system catches and throw a particular error\n- debug bool= False | True\n - This property will track any prompt while working\n\n## catchCommand()\n- after executed run() method, it allows us to get catch command list\n- show all cli command that matched to the added command\n- return list\n\n## getCommand()\n- show all added commands\n- return list\n\n## run()\n- find and match command via cli\n- Ex: python test.py -a=Miss -b=Mom\n\n## show()\n- display all added commands\n- if found commands, it will display all cough commands\n\n## Example 1\nCreate a test.py\n```\nfrom SmileArgs import SmileArgs\nsmile = SmileArgs(console= True, debug= True)\n# add command to list\nsmile.addCommand('a', 'alphabet', 'show alphabet')\nsmile.addCommand('b', 'baby', 'miss mom by her baby')\nsmile.addCommand('m', 'miss', 'miss mom everyday')\n\n# catch cli command\nprint(f'\\nFound commands via cli')\nsmile.run()\n\n# show\nsmile.show()\n\n```\nOn terminal try with this\n```\n$ python3.10 test.py -a -ab -a --miss=mom\n```\n<img width=\"853\" alt=\"test-smileargs\" src=\"https://github.com/sitthykun/smileargs/assets/227092/9855c13c-7400-4d2c-94ff-7c0508b7981a\">\n\n# Example 2\n\ncreate a testclass.py\n```\nfrom SmileArgs import SmileArgs\n\nclass TestClass:\n def __init__(self):\n \"\"\"\n \"\"\"\n # private\n self.__smile = SmileArgs()\n self.__load()\n \n def __load(self) -> None:\n \"\"\"\n \"\"\"\n self.__smile.addCommand('a', 'alphabet', 'show alphabet')\n self.__smile.addCommand('b', 'barbie', 'Wow, movies')\n self.__smile.addCommand('m', 'miss', 'miss mom everyday')\n \n def checkCLI(self) -> None:\n \"\"\"\n \"\"\"\n self.__smile.run()\n\n def executeCLICommand(self) -> None:\n \"\"\"\n \"\"\"\n #\n self.checkCLI()\n # \n for s in self.__smile.catchCommand():\n print(f'{f.cmdShort or f.cmdLong} \\t\\t{f.value}')\n \n\ntestClass = TestClass()\ntestClass.executeCLICommand()\n```\n\n## cli\n```\n$ python3.10 testclass.py -a -ab -a --miss=mom\n```\nit will catch '-a' as a short command, and '--miss' as a long command;\nthen use match or if statement to control those states.\n\nIt is available on **PyPi** store via https://pypi.org/project/SmileArgs/ \\\nTo Support my work, please donate me via <a class=\"bmc-button\" target=\"_blank\" href=\"https://www.buymeacoffee.com/sitthykun\"><img src=\"https://cdn.buymeacoffee.com/buttons/bmc-new-btn-logo.svg\" alt=\"Buy me a Pizza\"><span style=\"margin-left:5px;font-size:28px !important;\">Buy me a Coffee</span></a>\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "It is a modern args catching with python3 and OOP structure and implementation.",
"version": "1.1.2",
"project_urls": {
"Homepage": "https://github.com/sitthykun/smileargs"
},
"split_keywords": [
"argument",
"args",
"cli controller"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3c49a33fd314e8c2eccdeb12a2111ec2c74dbcab25c27cfb2ea14f3689daf2e7",
"md5": "7e063f9fd54872768d75dcc5403e79cf",
"sha256": "fc6064974f9069c35de8bd9ffdef09f6da5ef87a6891cbaa94a07c47439f2602"
},
"downloads": -1,
"filename": "SmileArgs-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7e063f9fd54872768d75dcc5403e79cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6230,
"upload_time": "2024-01-07T08:32:00",
"upload_time_iso_8601": "2024-01-07T08:32:00.339465Z",
"url": "https://files.pythonhosted.org/packages/3c/49/a33fd314e8c2eccdeb12a2111ec2c74dbcab25c27cfb2ea14f3689daf2e7/SmileArgs-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3183bd857cc23973a97193979898bc337c4217930cc4a1c3f3f74bbf70e9e19e",
"md5": "027f9945e4cf6aea7906fdbefefd7c82",
"sha256": "17557fee880b845e18c32240af13f3daa613aabc2c1df4b1de6fa772743ca780"
},
"downloads": -1,
"filename": "SmileArgs-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "027f9945e4cf6aea7906fdbefefd7c82",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6100,
"upload_time": "2024-01-07T08:32:02",
"upload_time_iso_8601": "2024-01-07T08:32:02.155650Z",
"url": "https://files.pythonhosted.org/packages/31/83/bd857cc23973a97193979898bc337c4217930cc4a1c3f3f74bbf70e9e19e/SmileArgs-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-07 08:32:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sitthykun",
"github_project": "smileargs",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "smileargs"
}