Code Monkey home page Code Monkey logo

clap's People

Contributors

bbugyi200 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

clap's Issues

Add `short_help` option to `clap.main_factory()` function

  • The clap.main_factory() function now accepts a short_help keyword option.
  • This option accepts values of type bool | str and defaults to False (uses first line of __doc__ if True is provided).
  • If this option is provided, the final CLI will require you use --help for the full help documentation (-h will show only a subset of the documentation that --help will show).

Use type inference of pydantic settings class to create ArgumentParser

  • The following client code should work (see pydantic.BaseSettings for more information on pydantic's settings management):
### dummy.py

import clap


class Context(clap.Context):
    foo: str
    bar: int = 4


def run(ctx: Context) -> int:
    assert isinstance(ctx.foo, str)
    assert isinstance(ctx.bar, int)
    return 0


main = clap.main_factory(run)
  • The foo and bar arguments should be derived from the following sources, ordered from least-preferred to most-preferred:
    • Default value (if specified) in Context class.
    • Global YAML configuration file (e.g. ~/.config/clap.yml).
    • Project-specific YAML configuration file (e.g. dummy.yml).
    • Environment variables (e.g. DUMMY_FOO or DUMMY_BAR) or .env file(s).
    • Command-line arguments (e.g. -f|--foo or -b|--bar).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.