Skip to main content

wrapper for argsparser to make more human the definition of the parser

Project description

chibi_argsparser

https://img.shields.io/pypi/v/chibi_argsparser.svg Documentation Status

wrapper for ArgumentParser to make more human the definition of the parser

Chibi_argparser vs ArgumentParser

Chibi_argparser

from chibi_argsparser import Chibi_args

parser = Chibi_args( "small example for ArgumentParser" )
parser.log_level.params = [ '--log_level' ]
parser.log_level.help = "level of logger"
parser.log_level.default = "INFO"

parser.command.set_as_subparser()
parser.command.help = "sub-comamnd help"

parser.command.list.help = "list the backups"
parser.command.backup.help = "do a backups"

parser.command.backup.block.params = [ "-b", '--block' ]
parser.command.backup.block.help = "block"
parser.command.backup.block.kind = Chibi_path
parser.command.backup.block.required = True

parser.command.profile.set_as_subparser()
parser.command.profile.dest = "profile_command"

parser.command.profile.backup
parser.command.profile.list
parser.command.profile.restore

ArgumentParser

from chibi_argsparser import Chibi_args
from argparse import ArgumentParser

parser_argparser = argparse.ArgumentParser(
        description="small example for ArgumentParser" )

parser_argparser.add_argument(
        "--log_level", dest="log_level", default="INFO",
        help="level of logger", )

sub_parsers = parser.add_subparsers(
        dest='command', help='sub-command help' )
parser_list = sub_parsers.add_parser( 'list', help='list the backups', )
parser_backup = sub_parsers.add_parser( 'backup', help='do a backup', )

parser_backup.add_argument(
        '--block', '-b', required=True, type=Chibi_path, help='block' )

profile_parser = sub_parsers.add_subparsers(
        dest='profile_command', help='', )

profile_parser.add_argument(
        '--block', '-b', required=True, type=Chibi_path, help='block' )

parser_backup = sub_parsers.add_parser( 'backup', )
parser_list = sub_parsers.add_parser( 'list', )
parser_list = sub_parsers.add_parser( 'restore', )

results

from chibi_argsparser import Chibi_args
from argparse import ArgumentParser

params = [
        "profile", '--block', '/dev/sda', 'backup', '--other', '--home' ]

# parser Chibi_args
result = parser( params )
# parse ArgumentParser
result_argparser = parser_arg_parser.parse_args( params )

assert result.command.list == False
assert result.command.profile == True
assert result.command.backup == False

assert result_2.command == "profile"
assert result.log_level == result_2.log_level
assert result.block == result_2.block

assert result.profile_command.list == False
assert result.profile_command.restore == False
assert result.profile_command.backup == True
assert result_2.profile_command == "backup"

assert result.home == result_2.home
assert result.other == result_2.other

assert result == {
        'block': '/dev/sda',
        'command': {'backup': False, 'list': False, 'profile': True},
        'home': True,
        'log_level': 'INFO',
        'other': False,
        'profile_command': {'backup': True, 'list': False, 'restore': False}
}

assert result_argparser == {
        'block': '/dev/sda',
        'command': 'profile',
        'home': True,
        'log_level': 'INFO',
        'other': False,
        'profile_command': 'backup'
}

History

1.1.1 ( 2026-04-26 )

  • se agrego el parametro de –log_level al parser en common

1.1.0 ( 2026-03-28 )

  • se agrego la clase common en los chibi args con el argumento de log_level

1.0.1 ( 2026-03-27 )

  • se agrega dependencia chibi_atlas a setup.py

1.0.0 ( 2026-03-27 )

  • se agrega clase Chibi_args y Chibi_arguments ambos siendo hijos de chibi_atlas

  • se agrego ejemplo de compatibilidad con ArgumentParser en readme

  • prueba unitaria de compatibilidad

0.0.1 ( 2026-03-26 )

  • First release on PyPI.

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

chibi_argsparser-1.1.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chibi_argsparser-1.1.1-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file chibi_argsparser-1.1.1.tar.gz.

File metadata

  • Download URL: chibi_argsparser-1.1.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for chibi_argsparser-1.1.1.tar.gz
Algorithm Hash digest
SHA256 2332fa95790275dfa5e2f78172fd5a818c6129e8c173b1923ad8aa135e156a1a
MD5 3ed44a3e760de58ae973ed6736755ab1
BLAKE2b-256 48f2f749b567c4dfedd4454c4e8fccb5491f5620a8c5d4abcf9ff51287f1570c

See more details on using hashes here.

File details

Details for the file chibi_argsparser-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for chibi_argsparser-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 71e3ba282180867302a9a05c1d006e4aaed2ff226563d0bbbe68da91fd30ecb5
MD5 0e61da4a798ce26c9a0e10a5918bdf02
BLAKE2b-256 a1f7925715b758b0fc2b48611d20f419a3f9ba48b3e7c4e5d36da555a6bf3f03

See more details on using hashes here.

Supported by

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