Lightweight library for use of defining functions and parameters that can be called from CLI or from other functions
Project description
runandcliscaffold
Lightweight library for use of defining functions and parameters that can be called from CLI or from other functions
Classes can now be defined in a simpler format that focus on business logic while enabling content for CLI running OR being called as a script
For example, a class definition:
from runandcliscaffold import RunAndCliScaffold
class fakeImplementation(RunAndCliScaffold):
def __init__(self):
super().__init__("TESTING")
def hello(self, args):
ret = f"{args.greeting}, {args.name}!"
print(ret)
return ret
def goodbye(self, args):
ret = f"{args.greeting}, {args.name}!"
print(ret)
return ret
def _defineFunctionsWithArgs(self):
return {self.hello: [{"short": "n", "long": "name", "default": "Tj", "type": str,
"help": "test1: beginning of data collection time period"},
{"short": "g", "long": "greeting", "default": "Hello", "type": str, "required": False,
"help": "greeting to use"}
],
self.goodbye: [{"short": "n", "long": "name", "default": "Tj", "type": str,
"help": "test1: beginning of data collection time period"},
{"short": "g", "long": "greeting", "default": "Goodbye", "type": str, "required": False,
"help": "greeting to use"}
],
}
can be called through command line:
python myscript.py hello -n Mark -g Wassup
and returns:
Wassup, Mark!
the equivelant call from script:
testclass = fakeImplementation()
ret = testclass.run(['hello', '--g', 'Wassup', '--n', 'Mark'])
also returns the value:
Wassup, Mark
While enabling an app to be run out as CLI, this also has usage as a test mechanism or as a self contained unit for consumption of other scripts.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file runandcliscaffold-0.2.tar.gz
.
File metadata
- Download URL: runandcliscaffold-0.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22220e9ceb6f8212cb5376977a151573ff8e2cfc1bd81636e507ebd768554f6f |
|
MD5 | 2a24bc55617708f1d1c9a7fc9b70490e |
|
BLAKE2b-256 | dbb0b0718fac56616386221871ce5c2f537c26e99be250def41919a1a484070d |
File details
Details for the file runandcliscaffold-0.2-py3-none-any.whl
.
File metadata
- Download URL: runandcliscaffold-0.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e0d83d07482d9cb7325ba50f17165bda87651db058476b84db5078ee785742 |
|
MD5 | 526b73f5dbc1e9f06cec3bb464b939d3 |
|
BLAKE2b-256 | 965fd7f923693e0115889a6f611dd74dec35f0a13db773a9423073b9a34d8bfe |