ryukinix / mal

MAL: A MyAnimeList Command Line Interface [BROKEN: BLAME MyAnimeList]
https://mal.readthedocs.io
Other
109 stars 9 forks source link

[solved] Unable to search usernames that start with dash #79

Closed ghost closed 6 years ago

ghost commented 6 years ago

mal is currently unable to search usernames that start with a dash, mal list --user "-Bass" returns the following error

usage: mal list [-h] [--extend] [--user USER] [section]
mal list: error: argument --user: expected one argument

After browsing it seems like this is an upstream bug in python, https://bugs.python.org/issue9334

Is there any workaround to this?

ryukinix commented 6 years ago

Thanks for filling this issue. Yes, seems a really old bug of argparse. Some funny answers of people wanting optparser get be un-deprecated.

For now, I don't know any workaround. Maybe would be possible escape the argument as /-Bass and remove / internally since this character is not possible inside of username because conflicts with HTTP URL. But this solution is a quite awful... and I think that there is no hope for argparse since is a bug of almost 8 years.

I need think a little about it.

ryukinix commented 6 years ago

Actually, there is a workaround:

mal list --user=-Bass
ghost commented 6 years ago

Just tested it and it works, thanks man.

ryukinix commented 6 years ago

Since this is a problem with argparse and not correlated with mal, I'm closing this. I hope you enjoy the software, @sothym

bradenbest commented 6 years ago

Strange. Why doesn't mal list --user -- -Bass work? The -- is meant to tell the arg parser that every arg from here on out is to be interpreted literally. I.e. ignore -. I always implement this in my user interfaces. And it also exists in the coreutils:

cd -- -some-dir # cd to ./-some-dir/
rm -- -r # remove the file named "-r"
ls -l -- -l # lists -l if it exists, in long form

I would absolutely expect an arg parsing library to implement this, so it's strange that it doesn't.

Either way, good workaround.

ryukinix commented 6 years ago

Yes, this is a common thing on gnu stuff, but until I now argparse is not correlated to gnu software.