Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems like this is supported, but I can't get multiple arguments to work #38

Closed
colinta opened this issue Jul 18, 2012 · 14 comments
Closed
Labels

Comments

@colinta
Copy link

colinta commented Jul 18, 2012

This is the docstring for punt.

I would like to have multiple --watch options, but I can't figure out a syntax that supports it.

"""Watches current path (or another path) for changes and executes
command(s) when a change is detected.  Uses watchdog to track file changes.

Usage:
    punt [-w <path> ...] [-l] [--] <commands>...
    punt (-h | --help)
    punt --version

Options:
    -w <path> ..., --watch <path> ...  Which path to watch [default: current directory]
    -l, --local                        Only tracks local files (disables recusive)
"""
# blablabla
arguments = docopt(__doc__, version='punt v1.6')
print repr(arguments)
> punt -w dir1 dir2  -- make
{'--': False,
 '--help': False,
 '--local': False,
 '--version': False,
 '--watch': 'dir1',
 '-h': False,
 '<commands>': ['dir2', '--', 'make']}

> punt -w dir1 -w dir2  -- make
{'--': True,
 '--help': False,
 '--local': False,
 '--version': False,
 '--watch': 'dir2',
 '-h': False,
 '<commands>': ['make']}
@keleshev
Copy link
Member

I'm sorry, but at this point only multiple positional arguments are supported. When I have time I plan to implement the syntax for multiple options:

-w <path> ...

@colinta
Copy link
Author

colinta commented Jul 18, 2012

Just wanted to make sure I wasn't using it wrong! :-)

@colinta colinta closed this as completed Jul 18, 2012
@keleshev
Copy link
Member

I will reopen this issue, since this is something I want "todo".

BTW, will be interesting to see: what workaround are you going to make? or stop using docopt?

@keleshev keleshev reopened this Jul 18, 2012
@colinta
Copy link
Author

colinta commented Jul 18, 2012

I dunno, I don't want to promise that i'll look at the code and send a pull request, but I might.

The multiple-watch-folders thing is not a feature that I urgently need, so sticking with docopt for now! :-)

@keleshev
Copy link
Member

@colinta I added support for the syntax [-w <path> ...] which can be used as > punt -w dir1 -w dir2. It is now in experimental branch.

After more testing this will get into master branch and then released as 0.5.0 to PyPI during the upcoming week.

Any feedback is appreciated.

@colinta
Copy link
Author

colinta commented Jul 29, 2012

I'll play with it and let you know if I find anything. Thanks!

@colinta
Copy link
Author

colinta commented Aug 1, 2012

http://github.com/colinta/punt/tree/experimental/

It works great! Thanks Vladimir! I'll leave it on my experimental branch until this gets merged into master.

@keleshev
Copy link
Member

keleshev commented Aug 1, 2012

Great! I'll close this issue as soon as this change is on PyPI.

@keleshev
Copy link
Member

0.5.0 is now out and on PyPI

@colinta
Copy link
Author

colinta commented Aug 13, 2012

Thanks for the heads up, Vladimir! punt v1.8 can be released!

@shabbyrobe
Copy link
Member

Woohoo! I will bring the PHP port up to speed tonight.

@kyle-fritz-zocdoc
Copy link

Is there a way to specify multiple options in a similar way, but using the [options] shortcut as part of the usage section? The following didn't seem to work for me:

Naval Fate.

Usage:
  naval_fate.py ship [options]

Options:
  --speed <kn> ...  Speed in knots.

argv: ship --speed=20 --speed=30

@keleshev
Copy link
Member

@kyle-fritz-zocdoc no, unfortunately (or luckily).

@binarytrails
Copy link

In of my projects, I tried to use this feature with the -e option in the following line:

script.py [-v] (-i) <interface> [-e <ip> -c] ((-h) <directory> | (-f) <frontend> (-a) <address>)

So it looks like:

script.py [-v] (-i) <interface> [-e <ips> ... -c] ((-h) <directory> | (-f) <frontend> (-a) <address>)

I also tried:

script.py [-v] (-i) <interface> [-e <ips> ...] [-c] ((-h) <directory> | (-f) <frontend> (-a) <address>)

Unfortunately, it does not works. Any suggestions?

UPDATE
I solved this issue by moving the -e to the end:

script.py [-v] (-i) <interface> [-c] ((-h) <directory> | (-f) <frontend> (-a) <address> [-e <ips> ...])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants