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

Merge #548 and #552 #553

Merged
merged 7 commits into from Oct 26, 2016
Merged

Merge #548 and #552 #553

merged 7 commits into from Oct 26, 2016

Conversation

jas32096
Copy link
Contributor

Closes #548 and #552

@jas32096
Copy link
Contributor Author

Alright. Should be working now, with the new syntax.

Note: For invoking from the command line, you'll need to surround the search with quotes like:
    mpsyt '/best music -d long -a year'

@ids1024
Copy link
Contributor

ids1024 commented Oct 26, 2016

I found an issue with this. If you try a command like /query --some-invalid-argument or /query --help, it prints a message then exits. The message is fine, but it shouldn't terminate mpsyt.

I don't know if there is a way to change that behavior with argparse. I don't see anything in the docs.

Edit: It looks like getopt raises an exception instead of exiting, so it may be more suitable. I think argparse is better though if there is a way to achieve this.

@jas32096
Copy link
Contributor Author

Right. I also forgot about passing on extra args with, kwargs, but I'm not gunna do that, for the time being. I'll try surrounding the parse with a try/except

@jas32096
Copy link
Contributor Author

Made some changes and really tried to beat it up this time.

One of the last things I tested with was / --this -qwerty -a 2015-09-22 this is a test --duration long --bad -c --, which is was able to handle fine, ignoring the unused arguments.

@ids1024 ids1024 merged commit 9204f12 into mps-youtube:develop Oct 26, 2016
videoDuration = args.duration if args.duration else 'any'
after = args.after
term = ' '.join(args.search)
except SystemExit as e: #<------ argsparse calls exit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't know that sys.exit() triggers a catchable exception. Nice!

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