Skip to main content

A helper for type-checked command-line argument store

Project description

test workflow

init_attrs_with_kwargs

A helper for type-checked command-line argument store.

Sample

from init_attrs_with_kwargs import InitAttrsWKwArgs

class MyArgs(InitAttrsWKwArgs):
    count: int
    name: str
    max_length: int

# Initialize from docopt's return value, with casting str to int
args: MyArgs = MyArgs(_cast_str_values=True, **{'<count>': '1', '--name': "Joe", '--max-length': '100'})

print("args.count=%s" % repr(args.count))
print("args.name=%s" % repr(args.name))
print("args.max_length=%s" % repr(args.max_length))

Another samples:

  • sample1.py. Describes data type conversion and error handling.
  • sample2.py. Storing docopt-parsed command line arguments in a type-hinted class's object.

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

init_attrs_with_kwargs-0.1.5.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

init_attrs_with_kwargs-0.1.5-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

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