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

Add simple command-line interface #43

Merged
merged 2 commits into from Nov 17, 2019

Conversation

merwok
Copy link
Contributor

@merwok merwok commented Nov 16, 2019

For #42

Usage: python -m shortuuid
@skorokithakis
Copy link
Owner

This needs more, for example using argparse to properly show the help text if the command is called with arguments, to show the version, etc. It also needs to be added to the scripts part of the setup.py so it gets properly installed as a command on installation.

@ghost
Copy link

ghost commented Nov 16, 2019

If you're willing to pull in an external dependency, I've had good luck with https://github.com/google/python-fire for command-line interfaces.

@skorokithakis
Copy link
Owner

Unfortunately I think that's too heavy for a minor feature in this case.

@merwok
Copy link
Contributor Author

merwok commented Nov 16, 2019

In the initial feature request I was seeing this more as a bonus, like the easter eggs in the standard library (python3 -m tarfile or python3 -m http.server). If you do want this as a standalone script with docs and all, I’ll have to spend more time on it 🙂

For command-line interface, given the Python versions supported by the project, argparse is not always available but really I would just use len(sys.argv) to see if we got 0, 1 (length) or 2 (length and number) params (inspiration from pwgen: https://linux.die.net/man/1/pwgen)

@merwok merwok changed the title Add command-line interface Add simple command-line interface Nov 16, 2019
@skorokithakis
Copy link
Owner

Hmm, this is true, I guess argparse is 3.2+. I guess I'm just not a fan of having utilities that don't support at least -h, but if this is an easter egg that's undocumented and not to be relied upon, I guess this is fine.

@skorokithakis skorokithakis marked this pull request as ready for review November 17, 2019 13:45
@skorokithakis skorokithakis merged commit c79ba35 into skorokithakis:master Nov 17, 2019
@merwok merwok deleted the add-cli branch November 17, 2019 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants