Skip to main content

a free layer to create logics for your arguments

Project description

logicparser

A free layer to create logics for your arguments

Getting Started

logicparser is a python package that allow you to create logic and dependncies between CLI arguments. These instructions will install logicparser to your machine.

Prerequisites

  • Python3
  • PIP3

Installation

pip3 install logicparser 

Usage

Define arguments

The class used to create a new argument is imported in this way:

from logicparser import Argument

arg = Argument(arg_name='--arg-name')

metavar

arg = Argument(arg_name='--arg-name', metavar='ARG_VALUE')

action

arg = Argument(arg_name='--arg-name', action='store_true')

help

arg = Argument(arg_name='--arg-name', help='This message will be show when you will define -h arg')

Add relationships

require

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',))

conflict

You can define that an argument cannot be defined if other arguments are defined previously

arg = Argument(
    arg_name='arg-name',
    conflict=('--other-arg',))

dependency

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',))

Parse arguments

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

Contributing

Please read CONTRIBUTING.md for details on code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License, read LICENSE for details

Author

  • Giuseppe "mastrobirraio" Matranga - Initial work - Github

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logicparser-1.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

logicparser-1.2.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file logicparser-1.2.0.tar.gz.

File metadata

  • Download URL: logicparser-1.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.12

File hashes

Hashes for logicparser-1.2.0.tar.gz
Algorithm Hash digest
SHA256 83d7c358cd9dce7184e03d0efc48a562c528b5002e26e930af3cbfd51425577a
MD5 87dd3721ce3858283c1caabaf53fb986
BLAKE2b-256 e7ee173f77397425759a46e250f7f54e0e6f389e50d1747cd76cfae60dc048ac

See more details on using hashes here.

File details

Details for the file logicparser-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: logicparser-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.12

File hashes

Hashes for logicparser-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 986589fc494ded163d4164aad30ebc405a2f3e400d30d168bac3752967a8c714
MD5 db1a0ed5407cd8912ba5d8e320a82f62
BLAKE2b-256 16d961e9cc6028981ba270f00fa8d99b9fba84453d7e41bb7c4402e8ceb6cb37

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page