Open kendalldita opened 1 month ago
@kendalldita did you read http://docopt.org/ ?
Your questions seems not specifically related to docopts
bash parser but more about the docopt
(without S
) language, right?
You should also paste your code you're trying, in order to complete your question, if related to docopts
. For more general docopt
question probably stackoverflow would be a better place to ask.
https://stackoverflow.com/questions/tagged/docopt
Here is a sample with your input:
#!/usr/bin/env bash
# Usage: xsltproc --param=PARAM INPUT OUTPUT
# xsltproc --lang=LANG INPUT OUTPUT
#
# no PATH changes required if docopts binary is in the PATH already
PATH=..:$PATH
source ../docopts.sh
HELP=$(docopt_get_help_string $0)
version='0.1'
parsed=$(docopts -A myargs -h "$HELP" -V $version : "$@")
#echo "$parsed"
eval "$parsed"
# main code
for a in ${!myargs[@]} ; do
echo "$a = ${myargs[$a]}"
done
some use-case:
$ ./xsltproc.sh
error:
Usage: xsltproc --param=PARAM INPUT OUTPUT
xsltproc --lang=LANG INPUT OUTPUT
with string parameter --param
do what ever you want with.
$ ./xsltproc.sh --param='lang=en' id.xsl in.xml
OUTPUT = in.xml
--param = lang=en
INPUT = id.xsl
better would be to let docopts
parse it by introducing a --lang
parameter.
$ ./xsltproc.sh --lang=en id.xsl in.xml
OUTPUT = in.xml
--param =
INPUT = id.xsl
--lang = en
Yes. In general, I use software that tries to conform to standards, and try to find an audience that is also interested in both conforming to standards, and practical usages of those standards, while the vast majority of people only care about what is in front of their face at the moment. Then questions are shunted away to different environments designed to avoid anyone asking questions.
Thanks for enduring questions this far. I'll now go get my questions rejected on stack overflow.
Oh, sorry to read that your question was rejected on stackoverflow. 😒
There's way to ask for help, especially in open source and free software community, you may learn with interacting with friendly or not-so-friendly people. 😉
I posted on stackoverflow yesterday for testing, following our conversation.
You should notice as I mentioned about docopt
:
doctops
is in standby, waiting for me or a parser lover hacker around (and me too to help him or her to grant write access to the repos) You should, may be, read more carefully how people get answer for there question. What you could improve on what I saw on the issues we exchanged is:
Yes, this is long and sometime disappointing, sometime very grateful 🤷♀️
Java and other software has key/value pair parameters, e.g. the
lang
property:Another example:
The parameter name can be anything. Could something like that be represented in docopt syntax?