Giter Club home page Giter Club logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
The basic idea is good, though I don't like adding yet another parameter to
ArgumentParser. I see two alternatives that I'd probably be okay with:

(1) Move the add_subparsers method into _ArgumentGroup. This would make putting
subcommands under a heading just like putting anything else under a heading, and
you'd write something like::

    commands_group = parser.add_argument_group(title='subcommands')
    subparsers = commands_group.add_subparsers()
    ...

(2) Teach the add_subparsers() method about title= and description= parameters, 
and
if either of these are present, create the corresponding argument group and add 
the
subparser action there instead of to the _positionals list. This would be a 
little
less pure, since normally only groups add new headings, but it might be more
practical because you could write something like:

    subparsers = parser.add_subparsers(title='subcommands')
    ...

What do you think?

Original comment by [email protected] on 14 Jul 2009 at 1:28

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
I think I like (2) better, since (1) implies that you could have a separate 
subparser
for each group, which I don't think was the intention.  I guess there should 
only be
one subparser per parser, not group, right?

Original comment by [email protected] on 14 Jul 2009 at 8:12

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
Here's a patch that implements option two.

Original comment by [email protected] on 15 Jul 2009 at 8:39

Attachments:

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
Looks good, thanks for the patch. I'll try to get this committed this week.

Original comment by [email protected] on 21 Jul 2009 at 2:50

from argparse.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 12, 2024
Committed in r34. Thanks again for the patch!

Original comment by [email protected] on 26 Jul 2009 at 3:00

  • Changed state: Fixed

from argparse.

Related Issues (20)

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.