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

Proposal: leveraging DocOpt subcommands #76

Closed
rgreinho opened this issue Dec 31, 2015 · 6 comments
Closed

Proposal: leveraging DocOpt subcommands #76

rgreinho opened this issue Dec 31, 2015 · 6 comments

Comments

@rgreinho
Copy link
Contributor

I wrote a tutorial here (https://github.com/rgreinho/docopt-subcommands-example) which explains how to use DocOpt subcommands in a console application.

I think we should leverage this in order to be able to easily add options to the main command or the subcommands in the future.

link: PR #75

@retr0h
Copy link
Contributor

retr0h commented Dec 31, 2015

Totally agree.

/cc @bborysenko @abrown-sg

@rgreinho
Copy link
Contributor Author

rgreinho commented Jan 1, 2016

@retr0h Even with a way better command dispatcher to get rid of the if ... elif ... else that you dislike :)

https://github.com/rgreinho/docopt-subcommands-example#find-the-command-to-execute
https://github.com/rgreinho/docopt-subcommands-example/blob/master/main.py#L37-L43

@retr0h
Copy link
Contributor

retr0h commented Jan 1, 2016

@retr0h Even with a way better command dispatcher to get rid of the if ... elif ... else that you dislike :)

so sexy

@identifystation
Copy link
Contributor

The challenge we're facing when trying to implement this (which may be a DocOpt bug) is that long arguments don't seem to work in both forms. For example:

--platform=ubuntu WORKS
--platform ubuntu FAILS

The expected behavior is that both will work in DocOpt, however we've been unable to find a workaround with Remy's subcommand pattern that support this.

#81 implements as much of this as possible, however, by moving commands into individual classes. This is a win regardless since it's a significant simplification over what we were using previously. It will also be easy to drop in DocOpt subcommand support once the bug is resolved.

@rgreinho
Copy link
Contributor Author

rgreinho commented Jan 6, 2016

I filed an issue upstream: docopt/docopt#305.

@rgreinho
Copy link
Contributor Author

rgreinho commented Jan 9, 2016

@abrown-sg There was a mistake in my tutorial (that I fixed), and now the parameters for the arguments work both with and without the equal sign.

Basically there need to be an ellipsis ('...') after the args (looks like [<args>...]), so that the program can have multiple values. The issue was that --platform ubuntu was counted as 2 arguments, but as the ellipsis was not specified, only one argument was allowed.

If you can confirm that it works for your branch as well (I don't think you pushed it, so I could not try myself), then I'll close the issue that I filled upstream.

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

No branches or pull requests

3 participants