Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Switched from argparse to docopt #5

Merged
merged 2 commits into from
Jan 13, 2014
Merged

Switched from argparse to docopt #5

merged 2 commits into from
Jan 13, 2014

Conversation

dbrgn
Copy link
Contributor

@dbrgn dbrgn commented Jan 12, 2014

In case you're interested, this PR replaces the builtin argparse module with the external docopt module.

http://docopt.org/
https://github.com/docopt/docopt

It makes it much simpler to create command line interfaces. You just edit the documentation in the module docstring, and the interface automatically adjusts.

Example (using pdb):

$ python kort2osm.py -d -v -c 10
> /home/danilo/Projects/kort-to-osm/kort2osm.py(56)<module>()
(Pdb) arguments
{'--count': '10',
 '--dry': True,
 '--help': False,
 '--quiet': False,
 '--verbose': True,
 '--version': False}

I couldn't really test it because I don't want to actually commit something to OSM, but the CLI interface should be equivalent.

@metaodi
Copy link
Member

metaodi commented Jan 13, 2014

Thanks, I'll have a look at it. At first glance, it looks very good. I like the idea to generate the CLI from the docstring 😉

@ghost ghost assigned metaodi Jan 13, 2014
@dbrgn
Copy link
Contributor Author

dbrgn commented Jan 13, 2014

It's much easier to handle, as long as you don't need complicated data validation (which you could do with other libraries). It even supports subcommands à la git, as far as I know.

@metaodi
Copy link
Member

metaodi commented Jan 13, 2014

Yeah, I saw the reference to "schema" as a possibility to validate the arguments. Maybe I will add that later.

metaodi added a commit that referenced this pull request Jan 13, 2014
Switched from argparse to docopt
@metaodi metaodi merged commit 30cf9ad into kort:develop Jan 13, 2014
@metaodi
Copy link
Member

metaodi commented Jan 13, 2014

Looks good, thanks!

@dbrgn dbrgn deleted the docopt branch January 13, 2014 16:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants