A lightweight object oriented lib for Python 3.8+ to help create CLI programs more easily. It has an elegant design taking advantage of built-in modules, and delivering a conducive environment to fast development and readability.
Project description
Argila Parser
Argila Parser
What is it?
It's a lightweight object oriented lib for Python 3.8+ to help create CLI programs more easily. It has an elegant design taking advantage of built-in modules, and delivering a conducive environment to fast development and readability.
Quickstart
This is the basic structure of your program, the class App
represents the application, and the methods within it are the commands.
The typing
module provides a built-in range of type hints, giving the developer a sophisticated way of accepting complex arguments. Any, Union, Tuple, List
are currently supported.
import typing
from argila import Argila
@Argila.create
class App:
@Argila.command(
{
'name': 'add',
'positional': {
'a': 'First element of the equation',
'b': 'Second element of the equation'
}
}
)
def add(self, a: typing.Union[int, float], b: typing.Union[int, float]) -> None:
'''This command adds two numbers together'''
print(a + b)
if __name__ == '__main__':
Argila.run()
A method is only considered a command if it has the @Argila.command
decorator.
Below is the configuration dict in its completeness.
{
'name': 'command',
'positional': {
'a': 'Obligatory argument'
},
'optional': {
'b': 'Optional argument'
},
'keyword': {
'c': 'Keyword argument'
}
}
* means the key is obligatory.
name*: The name of the command used to call it. (This is the only nomination that matters, the method can have any name you'd like)
positional: A dict with all the positional arguments, the key
should have the same name as the actual parameter in the method; the value
is a short description of it. You invoke this argument with --key value
.
optional: Same as positional, but optional arguments are not obligatory. You invoke this argument with --key value
.
keyword: Same as positional, but keyword arguments are not obligatory and work as flags (bools). You invoke this argument with --key
.
The order in which you invoke each argument does not matter, as long as you keep the syntax --key value
. The examples add --a 1 --b 2
and add --b 2 --a 1
are both correct.
Apart from it, the docstring '''This command adds two numbers together'''
is how you set the description of a command. If not set, the description defaults to an empty string.
Lastly, call Argila.run()
, which is the method that will trigger all the subsequent others.
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 argilaparser-2.0.1.tar.gz
.
File metadata
- Download URL: argilaparser-2.0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f7bb592fc20f913f43308563ce54ea1722e8ae05eab6101cbd60ded77f513df |
|
MD5 | 61fb67481814ae8ec2b451c0d6cc0f48 |
|
BLAKE2b-256 | cf6a9e4e7d43f7f9004447e5867cc39536582656d0675bf41466d52567c99de3 |
File details
Details for the file argilaparser-2.0.1-py3-none-any.whl
.
File metadata
- Download URL: argilaparser-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a5dcb475ebadfc29a0b97a33777aef351a58c82d65ad4132198764a9f1cd6a |
|
MD5 | 9f9bab8634984fb70fa4c98cdded4864 |
|
BLAKE2b-256 | 5afd00fd7d7782ba6ac0ba9c73ff020809f766fe65715fc3dd57bf0c146e2a35 |