[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-18 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

Looks good to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-18 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Steven, can you go ahead and apply this?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-18 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

Applied in r87362.

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-17 Thread Steven Bethard

Steven Bethard steven.beth...@gmail.com added the comment:

The patch looks basically okay to me, though this line makes me nervous:

  dest += ' (%s)' % ', '.join(aliases)

Since this is just for help formatting, can't you just modify metavar instead? 
The dest is the attribute on the namespace where the result should be stored. 
The metavar is the value that should be displayed in help messages.

As to where the aliases should be printed, I don't have a strong preference. 
The svn aliases show up when you do a generic svn help (but not if you do a 
svn help blame) and looks like:

Available subcommands:
   add
   blame (praise, annotate, ann)
   ...

The hg aliases show up when you do a hg help commit (but not if you do a hg 
help) and looks like:

hg commit [OPTION]... [FILE]...

aliases: ci

I guess the patch makes it pretty easy to emulate the svn version.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-17 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

I can see that this is really useful; approved for beta2 as soon as Steven's 
issue from the last message is handled.

--
assignee: georg.brandl - bethard
priority: normal - release blocker

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-17 Thread Adrian Sampson

Adrian Sampson asamp...@cs.washington.edu added the comment:

Thanks for the suggestion, Steven. I hadn't yet internalized the difference 
between dest and metavar.

This version of the patch modifies metavar instead. Because it looks like this 
issue is up for 3.2b2, I've modified NEWS and ACKS (I hope this was the right 
thing to do).

I also see the logic behind both help styles Steven depicts. If there's any 
interest, I can implement the other (hg) style or make it an option.

--
Added file: http://bugs.python.org/file20101/argparse-aliases.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-16 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Georg, I believe this should go in 3.2.
The alias capability is an essential part
of what subparsers are all about and
these absence of aliases would leave them
partially crippled (i.e. unable to emulate
the likes of svn blame/annotate/praise).

Please approve for the second beta.

--
assignee:  - georg.brandl
versions: +Python 3.2 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-15 Thread Adrian Sampson

Adrian Sampson asamp...@cs.washington.edu added the comment:

Great. I've added a simple example to the documentation for argparse. I also 
added a space to the comma separator in the alias list, but I'm worried that 
adding 'aliases:' will make the help less readable (especially if every command 
in a long list has aliases).

--
Added file: http://bugs.python.org/file20073/argparse-aliases.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-15 Thread Łukasz Langa

Łukasz Langa luk...@langa.pl added the comment:

Georg, be our hero here. I would be disappointed if this missed 3.2 and made us 
wait another 18 months (or 3 years for Linux distribution inclusion) for that 
feature.

This feature makes the first edition of argparse in py3k complete in terms of 
subcommands.

--
nosy: +georg.brandl, lukasz.langa

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-15 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Looks good and ready to me.

Regarding “alias” in help text, note that Mercurial prints it (using one line 
for them) but Subversion puts aliases in parentheses just after the main 
command name, which works very for me (not a beginner).  Stephen, what do you 
think?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Patch looks good.  Can you add tests for the new functionality?  (This is 
listed in the link I gave you :)

Note: this code

if 'aliases' in kwargs:
aliases = kwargs.pop('aliases')
else:
aliases = ()

can be shortened to

aliases = kwargs.pop('aliases', ())

--
versions: +Python 3.3 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-13 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

+1 on this feature request

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-13 Thread Adrian Sampson

Adrian Sampson asamp...@cs.washington.edu added the comment:

Sorry I'm slow. Here's a new patch that includes tests. I'll also write 
documentation if that would be helpful, although I'm not very familiar with the 
style recommendations.

--
Added file: http://bugs.python.org/file20034/argparse-aliases.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the quick update!

+1 (1alias1,1alias2)
I think there should be a space after the comma.  Maybe “aliases:” could also 
be prepended, for clarity.

Help about the docs: http://docs.python.org/dev/documenting/

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-12-12 Thread Adrian Sampson

Adrian Sampson asamp...@cs.washington.edu added the comment:

Thanks for the pointer, Éric. Here's a quick patch that integrates the same 
functionality into the existing subparser class.

--
keywords: +patch
Added file: http://bugs.python.org/file20026/argparse-aliases.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-11-27 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

It seems to me that this alias functionality should be integrated into the 
subparsers code, not another action.  Guidelines for patches are at 
http://www.python.org/dev/patches/  Thanks in advance.

(Complementary idea for another bug report: Automatically recognize unambiguous 
shortened commands, see for example “hg d” which expands to “hg diff”.)

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-07-13 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +bethard
versions: +Python 3.2 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9234] argparse: aliases for positional arguments (subparsers)

2010-07-12 Thread Adrian Sampson

New submission from Adrian Sampson asamp...@cs.washington.edu:

The argparse module supports subparsers, which allow CLI tools to support 
invocation of subcommands (much like the svn or hg programs). For these 
subcommands, it is often useful to allow multiple names for the same command. 
For instance, in Mercurial, hg blame does the same thing as hg annotate.

You should be able to create subparsers with command aliases, like this:
 subparsers.add_parser(annotate, aliases=('ann', 'blame'))

The help message for the program should display the aliases alongisde the 
command names.

I'm attaching an example script that adds an Action to the library to 
accomplish this. This isn't a patch, but if this approach seems right to other 
people, I'll turn it into a patch.

Here's this bug on argparse's old tracker:
http://code.google.com/p/argparse/issues/detail?id=23

--
components: Library (Lib)
files: aliases.py
messages: 110130
nosy: asampson
priority: normal
severity: normal
status: open
title: argparse: aliases for positional arguments (subparsers)
type: feature request
versions: Python 2.7
Added file: http://bugs.python.org/file17971/aliases.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9234
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com