CLI argument/options and default behaviours #1
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Blocks
#2 Choix du répertoire de téléchargement temporaire
fcode/delarte
Reference: fcode/delarte#1
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
en: the project seems to work on my machine with the example given in README.md, but optionnal and/or needed arguments are not listed anywhere. maybe a documentation on usage would help if the script is getting more complex.
this may look like a simple man page:
a suggestion would be to put this information in README.md, by adding a prototype Part in "Chauffe Marcel".
fr: le projet semble fonctionner normalement sur ma machine avec l'exemple donné dans le README.md, mais la liste des arguments qu'on peut et/ou doit entrer n'est accessible nulle part. peut-être qu'un mode d'emploi serait utile si le script était amené à devenir plus complexe.
ça pourrait ressembler à une simple page de man:
une idée simple, serait de mettre cette information dans le fichier README.md, en séparant la partie installation du projet "Chauffe Marcel", d'une nouvelle partie "prototype"
Merci pour la proposition 👏
L'idée est d'ajouter la gestion des arguments avec
argparse
pour ne pas avoir à mettre à jour leREADME.md
à chaque fois.[suggestion] missing documentationto Gérer les paramètres du script avec ArgparseThis has been addressed without argparse for now. Calling the script without argument (or calling it with either
-h
or--help
will show a usage message.Please mention the last branch, merge request or commit with the implementation related to this isse and close this issue if necessary
A good practice is to mention this issue in the commit message to ease following-up
Commit:
9593619c68
"A good practice is to mention this issue in the commit message to ease following-up" => wilco.
Hi @remace07 , it looks good for me too, see at line 48
If we are missing something, feel free to re-open this issue or open a new one related with this one.
Gérer les paramètres du script avec Argparseto CLI argument/optionsI reopen this because it is likely that a non-trivial cli args/opts management will become necessary regarding #11, #8 and #12.
CLI argument/optionsto CLI argument/options and default behavioursTaking the conversation from #17 over here as it is more a talk about user interface and functionalities than one about implementation.
To sum up, @remace07 proposes this interface:
Where I suggest:
So it is kind of a named parameters vs. positional parameters situation.
I pointed out that there is no use case for providing only
program_url
andresolution
(the only scenario enabled by using flags tha would not be possible in my suggestion).My response to #17
Understood however
version
andresolution
could be validated by theargparse
using simple regexps so it could be able to detect error and fail early. Although this would be a waste of time anyway as the validation can only really come after we downloaded the programs info (api
) then the version's available resolutions.All we need are nice error messages like
"720p" is not a valid version identifier, available values are: ...
I am not sure I understand what you mean by "userproof", but I guess if the users do not know/remember the usage prototype they will hit
-h
anyway and will be provided with information, whether if it is to remember that theversion
comes before theresolution
or to remember that-l
is the flag for theversion
.In other words, one can say "but positionnal arguments HAVE TO be given in the very order of the prototype" as much as one can say "but named arguments HAVE TO be given with the correct flag in front of them". The only way to know in both cases is to hit
-h
and read.I am not saying that flags must only be used for special cases (help message, version number, ...) or to overwrite default values or behaviours (human redable vs machine parsebale outputs, verbosity, logging...) but I am almost saying it =) For anything more complicated, groups (like with the git command) is probably more appropriate.
We have 3 usecases so far:
Unless we can already think of probable other scenarios to come, I don't see how flags helps us more.
True
that's what I meant.
though, the workflow you imagine (first get available versions, then get available renditions, then download the asked combo) makes the argument come in the very order.
so I think You're right, flags don't help a lot, for instance. it's just that I misunderstood something from documentation.
Thanks @remace07 for the initial push with about this issue !
I suggest we keep this issue open to discusse future options/default values strategy.
Ok, implementation remark:
Does anyone have experience with docopt ?
It works in reverse from most arument parser:
argparse
build parser programatically and is able to generate some usage string from it.docopt
does the oposite, you give it a usage string and it generates a parser for you.It would be an added dependency, but I find it very elegant (functionality dictates implementation and not the opposite), actually I ❤️ the idea :)
If someone wants to experiement...
PS: the project seems not in developement for a long while, but if it does the job...
Okay, the orignal project (docopt) has been dormant but there was a community fork made few years ago: docopt-ng
These options have been added to address output file naming (#8)
They all start with
--name-
so they can be easily gathered and passed to the naming routine.