A free layer to create logics for your arguments
logicparser is a python package that allow you to create logic and dependncies between CLI arguments. These instructions will install logicparser to your machine.
- Python3
- PIP3
pip3 install logicparser
The class used to create a new argument is imported in this way:
from logicparser import Argument
arg = Argument(arg_name='--arg-name')
arg = Argument(arg_name='--arg-name', metavar='ARG_VALUE')
arg = Argument(arg_name='--arg-name', action='store_true')
arg = Argument(arg_name='--arg-name', help='This message will be show when you will define -h arg')
You can define that an argument can be defined only if others arguments are defined previously
arg = Argument(
arg_name='arg-name',
require=('--other-arg',))
You can define that an argument cannot be defined if other arguments are defined previously
arg = Argument(
arg_name='arg-name',
conflict=('--other-arg',))
You can define that an arguments can be defined only if at least one of others arguments is defined
arg = Argument(
arg_name='arg-name',
dependency=('--other-arg1', 'other-arg2',))
When you have defined the list of your arguments you can play args validation parsing them.
from logicparser import Argument, ArgumentHandler
args = ArgumentHandler([
Argument(arg_name='--arg-name', ...),
Argument(arg_name='--arg-name2', ...),
Argument(arg_name='--arg-name3', ...),
...
]).args
Please read CONTRIBUTING.md for details on code of conduct, and the process for submitting pull requests.
This project is licensed under the MIT License, read LICENSE for details
- Giuseppe "mastrobirraio" Matranga - Initial work - Github