Name | autocall JSON |
Version |
1.1.1
JSON |
| download |
home_page | None |
Summary | Call function directly in command line and a well help tips generately automatically |
upload_time | 2024-06-19 12:49:15 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
command
line
call
function
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Call function directly in cmd line
#### Features
1. Allow user call functions directly in command line.
2. Generate help tips automatically.
3. Add default called functions if not function was specific.
#### Notice
1. It's better to add argument type for each autocall functions.
2. str type argument must be defined explicitly.
3. @cmdline_default is a subset of @cmdline, which means function with @cmdline_default will have @cmdline implicitly.
4. Arguments of function with @cmdline_default should be optional or no argument.
#### TODO
1. Support class's function with self as the first argument.
#### Code example
``` python
#!/bin/python3.8
from autocall import *
# The tar @cmdline is used to register the function.
@cmdline
def test1():
print(f'test1()')
pass
@cmdline
@cmdline_default
def test2(arg: int = 0):
print(f'test2({arg})')
pass
@cmdline
def test3(arg1, arg2: str = 'this is a string'):
print(f'test3({arg1}, {arg2})')
@cmdline
def test4(arg1, arg2: int):
'You can add some extra information here.'
print(f'test4({arg1}, {arg2})')
pass
@cmdline_default
def test5(arg1: int = 1, arg2: str = 'good'):
print(f'test5({arg1}, {arg2})')
# main function
parse_and_run()
```
#### Run the code
``` bash
~/autocall/src $ ./test.py --help
Help Tips Provided by Autocall.
option:
--test1
--test2 [arg = 0]
The function will be called directly if not specific.
--test3 arg1 [arg2 = this is a string]
--test4 arg1 arg2
You can add some extra information here.
--test5 [arg1 = 1] [arg2 = good]
The function will be called directly if not specific.
--help [verbose = notverbose]
Give the argument "verbose" instead of "notverbose" to print detail information.
~/autocall/src $ ./test.py --test5 10 'hello'
test5(10, hello)
~/autocall/src $ ./test.py
test2(0)
test5(1, good)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "autocall",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "bajeer <z_bajer@yeah.net>",
"keywords": "command, line, call, function",
"author": null,
"author_email": "bajeer <z_bajer@yeah.net>",
"download_url": "https://files.pythonhosted.org/packages/aa/fc/4ef2cff8e9ab5d08a796ac6d4dcd6fe77cf10cf2639ad4b0d333a17a0660/autocall-1.1.1.tar.gz",
"platform": null,
"description": "# Call function directly in cmd line\n\n#### Features\n1. Allow user call functions directly in command line.\n2. Generate help tips automatically.\n3. Add default called functions if not function was specific.\n\n#### Notice\n1. It's better to add argument type for each autocall functions.\n2. str type argument must be defined explicitly.\n3. @cmdline_default is a subset of @cmdline, which means function with @cmdline_default will have @cmdline implicitly.\n4. Arguments of function with @cmdline_default should be optional or no argument.\n\n#### TODO\n1. Support class's function with self as the first argument.\n\n#### Code example\n``` python\n#!/bin/python3.8\nfrom autocall import *\n\n# The tar @cmdline is used to register the function.\n@cmdline\ndef test1():\n print(f'test1()')\n pass\n\n@cmdline\n@cmdline_default\ndef test2(arg: int = 0):\n print(f'test2({arg})')\n pass\n\n@cmdline\ndef test3(arg1, arg2: str = 'this is a string'):\n print(f'test3({arg1}, {arg2})')\n \n@cmdline\ndef test4(arg1, arg2: int):\n 'You can add some extra information here.'\n print(f'test4({arg1}, {arg2})')\n pass\n\n@cmdline_default\ndef test5(arg1: int = 1, arg2: str = 'good'):\n print(f'test5({arg1}, {arg2})')\n\n# main function\nparse_and_run()\n```\n#### Run the code\n``` bash\n~/autocall/src $ ./test.py --help\nHelp Tips Provided by Autocall.\n option:\n --test1 \n\n --test2 [arg = 0] \n The function will be called directly if not specific.\n\n --test3 arg1 [arg2 = this is a string] \n\n --test4 arg1 arg2 \n You can add some extra information here.\n\n --test5 [arg1 = 1] [arg2 = good] \n The function will be called directly if not specific.\n\n --help [verbose = notverbose] \n Give the argument \"verbose\" instead of \"notverbose\" to print detail information.\n\n~/autocall/src $ ./test.py --test5 10 'hello'\ntest5(10, hello)\n~/autocall/src $ ./test.py\ntest2(0)\ntest5(1, good)\n```\n",
"bugtrack_url": null,
"license": "Copyright (c) 2016 The Python Packaging Authority (PyPA) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Call function directly in command line and a well help tips generately automatically",
"version": "1.1.1",
"project_urls": {
"Bug Reports": "https://gitee.com/z-bajer/autocall/issues",
"Homepage": "https://gitee.com/z-bajer/autocall",
"Source": "https://gitee.com/z-bajer/autocall"
},
"split_keywords": [
"command",
" line",
" call",
" function"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c80b057024859ff1e4456a20821125b912cf4af33db4bd150630d0b029a3010f",
"md5": "fb73487095b8b19ef1421d185e747fc9",
"sha256": "36d24c1d2cbc7732e7b3e2effcd6c2d2765ab1d25554414961c9f161aa31f724"
},
"downloads": -1,
"filename": "autocall-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb73487095b8b19ef1421d185e747fc9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5321,
"upload_time": "2024-06-19T12:49:08",
"upload_time_iso_8601": "2024-06-19T12:49:08.457563Z",
"url": "https://files.pythonhosted.org/packages/c8/0b/057024859ff1e4456a20821125b912cf4af33db4bd150630d0b029a3010f/autocall-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aafc4ef2cff8e9ab5d08a796ac6d4dcd6fe77cf10cf2639ad4b0d333a17a0660",
"md5": "4f0cc9be29be0ad69041e4279cb3fc6c",
"sha256": "7fe9711e971df4044276fb7cb1915f1d02aaabdff4f9adce3994f6c3cd140771"
},
"downloads": -1,
"filename": "autocall-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "4f0cc9be29be0ad69041e4279cb3fc6c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6522,
"upload_time": "2024-06-19T12:49:15",
"upload_time_iso_8601": "2024-06-19T12:49:15.679518Z",
"url": "https://files.pythonhosted.org/packages/aa/fc/4ef2cff8e9ab5d08a796ac6d4dcd6fe77cf10cf2639ad4b0d333a17a0660/autocall-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-19 12:49:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "autocall"
}