Giter Club home page Giter Club logo

pycli's Issues

Modify option for list type?

First, great tool! I was looking for something exactly like this for a long time and I was happy to find this.
I would like to know: would it be possible to have a different setup for list arguments? Right now, it requires calling the argument as many times as elements in the list (e.g. --my_list 1 --my_list 2 etc) which can be cumbersome for long list or long argument names. Another option would be to use the nargs option. I tested it and it works by modifying a few lines:
At

action = _parser.add_argument(name, action=action_name)
replace by:
action = _parser.add_argument(name, action=action_name, nargs=nargs)

with nargs set to 1 by default, and to '+' if annotation is iterable, here:

action_name = "append"

Let me know if you consider implementing it, otherwise, I'll fork the repository, but I would prefer to stick to this repo if I can since it can be easily installed with pip.

How to use with class methods, and can I add general options?

From reading the code I think it's possible to use this with class methods, but I don't know how, can you give a sample?

I also need to have global options to pass an optional token (something like --token <string>) to every command. Is there a way to specify this in one place and handle parsing centrally?

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.