Git Product home page Git Product logo

docopts's Introduction

docopts

docopt for shell - make beautiful CLI with ease.

Status: working.

docopts : the command line wrapper for bash.

Most concepts are documented in the docopt (without S) manual - see docopt.org.

Many examples use associative arrays in Bash 4+, but there is legacy support for Bash 3.2 on macOS (OS X) or legacy GNU/Linux OS.

This is a bug fix release: v0.6.4-with-no-mangle-double-dash

This release will be maintained for compatibility, only fixes will be provided. The 0.6.4 version is fully compatible with the previous version of docopts. Except for - handling in global mode, which produces an error.

SYNOPSIS

  docopts [options] -h <msg> : [<argv>...]
  docopts [options] [--no-declare] -A <name>   -h <msg> : [<argv>...]
  docopts [options] -G <prefix>  -h <msg> : [<argv>...]
  docopts [options] --no-mangle  -h <msg> : [<argv>...]

DESCRIPTION

docopts parses the command line argument vector <argv> according to the docopt string <msg> and echoes the results to standard output as a snippet of Bash source code. Passing this snippet as an argument to eval(1) is sufficient for handling the CLI needs of most scripts.

Global mode

Global mode, is the default historical output of docopts. It will output globals variable for storing parsed result.

If <argv> matches one of the usage patterns defined in <msg>, docopts generates code for storing the parsed arguments as Bash variables. As most command line argument names are not valid Bash identifiers, some name mangling will take place:

  • <Angle_Brackets> ==> Angle_Brackets
  • UPPER-CASE ==> UPPER_CASE
  • --Long-Option ==> Long_Option
  • -S ==> S
  • -4 ==> INVALID (without -G)

If one of the argument names cannot be mangled into a valid Bash identifier, or two argument names map to the same variable name, docopts will exit with an error, and you should really rethink your CLI, or use -A or -G. If the double-dash is part of the <msg> the matched item -- will be skiped.

Note: You can use --no-mangle if you still want full input, this wont produce output suitable for bash eval(1) but can be parsed by your own code. Double-dash -- will be kept.

-G is a variant of Global mode, which prefixes the globals mangled named with <prefix> + _ + Mangled_name. In this mode double-dash -- and single-dash - will be kept and will be mangled.

  • --Long-Option ==> prefix_Long_Option
  • -- ==> prefix___
  • - ==> prefix__

Note that prefixed invalid mangled names still raise an error, if they resolve to invalid bash identifier.

Prefix gobals variable makes it easy to filter variable with grep or such, or to avoid globals name collision.

Handling [-] in global mode is not supported and raises an error when trying to mangle -. But works for any other modes including -G. This behavior differs from python's version of docopts which would have skiped the positional - without error.

./docopts -h 'Usage: dump [-]' : -
docopts:error: Print_bash_global:Mangling not supported for: '-'

Single-dash can be catch easily by reading it into a FILENAME parameter:

./docopts  -h 'Usage: prog parse FILENAME' : parse -
parse=true
FILENAME='-'

then in your code:

f="$FILENAME"
if [[ $f == '-' ]] ; then
	f=/dev/stdin
fi

A working example is provided in examples/legacy_bash/cat-n_wrapper_example.sh

Associative Array mode

Alternatively, docopts can be invoked with the -A <name> option, which stores the parsed arguments as fields of a Bash 4+ associative array called <name> instead. However, as Bash does not natively support nested arrays, they are faked for repeatable arguments with the following access syntax:

    ${args[ARG,#]} # the number of arguments to ARG
    ${args[ARG,0]} # the first argument to ARG
    ${args[ARG,1]} # the second argument to ARG, etc.

Associative mode don't skip double-dash -- it will be part of the keys as boolean value present or not.

How arguments are associated to variables

What ever output mode has been selected.

The arguments are stored as follows:

  • Non-repeatable, valueless arguments: true if found, false if not. This include double-dash -- which must be specified as docopt syntax.
  • Repeatable valueless arguments: the count of their instances in <argv>
  • Non-repeatable arguments with values: the value as a string if found, the empty string if not
  • Repeatable arguments with values: a Bash array of the parsed values

Unless the --no-help option is given, docopts handles the --help and --version options and their possible aliases specially, generating code for printing the relevant message to standard output and terminating successfully if either option is encountered when parsing <argv>.

Note however that this also requires listing the relevant option in <msg> and, in --version's case, invoking docopts with the --version option.

If <argv> does not match any usage pattern in <msg>, docopts will generate code for exiting the program with status 64 EX_USAGE in sysexits(3) and printing a diagnostic error message.

Note that due to the above, docopts can't be used to parse shell function arguments: exit(1) quits the entire interpreter, not just the current function.

OPTIONS

This is the verbatim output of the --help:

Options:
  -h <msg>, --help=<msg>        The help message in docopt format.
                                Without argument outputs this help.
                                If - is given, read the help message from
                                standard input.
                                If no argument is given, print docopts's own
                                help message and quit.
  -V <msg>, --version=<msg>     A version message.
                                If - is given, read the version message from
                                standard input.  If the help message is also
                                read from standard input, it is read first.
                                If no argument is given, print docopts's own
                                version message and quit.
  -s <str>, --separator=<str>   The string to use to separate the help message
                                from the version message when both are given
                                via standard input. [default: ----]
  -O, --options-first           Disallow interspersing options and positional
                                arguments: all arguments starting from the
                                first one that does not begin with a dash will
                                be treated as positional arguments.
  -H, --no-help                 Don't handle --help and --version specially.
  -A <name>                     Export the arguments as a Bash 4+ associative
                                array called <name>.
  -G <prefix>                   Don't use associative array but output
                                Bash 3.2 compatible GLOBAL variables assignment:
                                  <prefix>_{mangled_args}={parsed_value}
                                Can be used with numeric incompatible options
                                as well.  See also: --no-mangle
  --no-mangle                   Output parsed option not suitable for bash eval.
                                Full option names are kept. Rvalue is still
                                shellquoted. Extra parsing is required.
  --no-declare                  Don't output 'declare -A <name>', used only
                                with -A argument.
  --debug                       Output extra parsing information for debugging.
                                Output cannot be used in bash eval.

COMPATIBILITY

Bash 4+ and higher is the main target.

In order to use docopts with Bash 3.2 (for macOS and old GNU/Linux versions) by avoiding bash >4.x associative arrays, you can:

  • don't use the -A option
  • use GLOBAL generated mangled variables
  • use -G <prefix> option to generate GLOBAL with prefix_
  • use -G switch with source docopts.sh --auto -G (see example)

The docopts.sh helper allows the use of set -u, which gives an error on undefined variables in your scripts.

Unofficial strict mode for bash should also work with docopts.sh, please report any issue with examples.

docopts.sh helper

The helper has its own documentation here docs/README.md.

EXAMPLES

Find more examples in examples/ folder. Please report any non working example by creating an issue with examples.

The following example reads the help and version messages from standard input (docopts found in $PATH):

source examples/legacy_bash/rock_hello_world.sh

#!/usr/bin/env bash
# Example from README.md

PATH=$PATH:../..
eval "$(docopts -V - -h - : "$@" <<EOF
Usage: rock [options] <argv>...

Options:
      --verbose  Generate verbose messages.
      --help     Show help options.
      --version  Print program version.
----
rock 0.1.0
Copyright (C) 200X Thomas Light
License RIT (Robot Institute of Technology)
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
EOF
)"

if $verbose ; then
    echo "Hello, world!"
fi

The following example, parses the help and version messages from script comments and pass them as command line arguments:

source examples/legacy_bash/rock_hello_world_with_grep.sh

#!/usr/bin/env bash
# Example from README.md
PATH=$PATH:../..

#? rock 0.1.0
#? Copyright (C) 200X Thomas Light
#? License RIT (Robot Institute of Technology)
#? This is free software: you are free to change and redistribute it.
#? There is NO WARRANTY, to the extent permitted by law.

##? Usage: rock [options] <argv>...
##?
##? Options:
##?       --help     Show help options.
##?       --version  Print program version.

help=$(grep "^##?" "$0" | cut -c 5-)
version=$(grep "^#?"  "$0" | cut -c 4-)
eval "$(docopts -h "$help" -V "$version" : "$@")"

for arg in "${argv[@]}"; do
    echo "$arg"
done

The next example shows how using the Bash 4+ associative array with -A:

help="
Usage: example [--long-option-with-argument=value] <argument-with-multiple-values>...
"
eval "$(docopts -A args -h "$help" : "$@")"

if ${args[subcommand]} ; then
    echo "subcommand was given"
fi

if [ -n "${args[--long-option-with-argument]}" ] ; then
    echo "${args[--long-option-with-argument]}"
else
    echo "--long-option-with-argument was not given"
fi

i=0
while [[ $i -lt ${args[<argument-with-multiple-values>,#]} ]] ; do
    echo "$i: ${args[<argument-with-multiple-values>,$i]}"
    i=$[$i+1]
done

Docopts History

docopts was first developed by Lari Rasku [email protected] and was written in Python based on the docopt Python parser.

The current version is written in go and is almost 100% compatible with previous Python-based docopts. See section Global mode for incompatibly details and provided work around.

Please report any non working code with issue and examples.

Roadmap: A new shell API is proposed

Starting at release: 0.7.0 a new lib API based on JSON will be introduced:

See and contribute on the docopts Wiki.

Install

You only have to drop the binary, and optionally also the docopts.sh lib helper, in a directory on your PATH. The binary is standalone and statically linked, so it runs everywhere.

See build section.

With root privileges you could do:

cp docopts docopts.sh /usr/local/bin

Pre-built binaries

Pre-built Go binaries for some OS (32 and 64 bits) are attached to releases.

We provide a download helper:

git clone https://github.com/docopt/docopts.git
cd docopts
./get_docopts.sh

You should get a renamed docopts in the current folder. Put it in your PATH:

sudo cp docopts docopts.sh /usr/local/bin

The cloned repository is no more used at this stage, but still contains a lot of bash examples.

Learn more about pre-built binaries.

Compiling

We encourage you to build your own binary, which is easy once you have Go installed. Or find a local golang developer that you trust and ask her, in exchange for a beer or two, if she could build it for you. ;)

Requires a Go workspace.

local build: (also done with our Makefile default target: make)

go get github.com/docopt/docopt-go
go get github.com/docopt/docopts
cd src/github.com/docopt/docopts
go build docopts.go

cross compile for 32 bit:

env GOOS=linux GOARCH=386 go build docopts.go

or via Makefile:

cd src/github.com/docopt/docopts
make all
make test

Tested builds are built on:

go version go1.17.1 linux/amd64

Features

Warning: may be not up-to-date feature list.

The docopts.sh helper is an extra bash library that you can source in your shell script. This library provides some bash helpers and is not required in order to use docopts. See docopts.sh documentation.

docopts doesn't need a python interpreter anymore, so it works on any legacy system too.

As of 2021-09-15

  • docopts is able to reproduce almost 100% of the python version.
  • unit tests for Go are provided, so hack as you wish.
  • 100% of language_agnostic_tester.py tests pass (GNU/Linux 64bits).
  • bats-core unittests and functional testing are provided too.

Developers

Read the doc for developer.

docopts's People

Contributors

aaronbpaden avatar agilgur5 avatar avaldebe avatar dexpota avatar florianheigl avatar nkakouros avatar phillmac avatar rdonkin avatar sylvain303 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docopts's Issues

check cheksum docopts in path can be python version and not golang compiled

If you relay on $PATH to execute docopts and docopts is the python version, you get misbehavior.

Especially using bash wrapper doctops.sh which doesn't stop on -h.

So some checks should be added inside docopts.sh wrapper to detect wrong executable to avoid caller script to continue its execution. Which may be quite wrong if the scripts rely on docopts to naturally stops it execution on -h

'exec format error' when using binary from 0.6.3-alpha1 release

OS: macOS Sierra 10.12.6

Darwin a.b.c.d 16.7.0 Darwin Kernel Version 16.7.0: Wed Feb 27 00:29:57 PST 2019; root:xnu-3789.73.43~1/RELEASE_X86_64 x86_64

When I tried to download the pre-built binary, I am unable to run it:

› curl -fsSL -o docopts https://github.com/docopt/docopts/releases/download/v0.6.3-alpha1/docopts && chmod +x docopts && ./docopts --help
zsh: exec format error: ./docopts

› file ./docopts
./docopts: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped

Thanks.

'Options:' part of help string is not printed on parse error

Tested on latest master dab1ec9 using bash 4.4.19(1)-release on Linux.

None of the examples scripts that have an 'Options:' section include this in the output when an invalid option is given. Also noticed on one of my own scripts.

Issue appears to be in docopts.go or in how its output is handled (see unit test below), as debugging of my shell script showed that docopts.sh was sending the complete usage string including 'Options:` section.

Examples:

$ grep Options: *.sh
arguments_example.sh:# Options:
calculator_example.sh:# Options:
cat-n_wrapper_example.sh:# Options:
naval_fate.sh:# Options:
rock_no-stdin_example.sh:# Options:
rock_stdin_example.sh:Options:

$ bash arguments_example.sh  -asdfasdf
error: 
Usage: arguments_example.sh [-vqrh] [FILE] ...
          arguments_example.sh (--left | --right) CORRECTION FILE
vagrant@vagrant:~/src/docopts/examples$ bash calculator_example.sh -asfasdf
echo 'error: 
Usage:
  calculator_example.sh <value> ( ( + | - | * | / ) <value> )...
  calculator_example.sh <function> <value> [( , <value> )]...
  calculator_example.sh (-h | --help)' >&2
exit 64
error: 
Usage:
  calculator_example.sh <value> ( ( + | - | * | / ) <value> )...
  calculator_example.sh <function> <value> [( , <value> )]...
  calculator_example.sh (-h | --help)

$ bash cat-n_wrapper_example.sh -asdfasdf
error: 
Usage: cat-n_wrapper_example.sh [--count=N] FILE...

$ bash rock_stdin_example.sh 
error: 
Usage: rock [options] <argv>...

$ bash naval_fate.sh -asdfasdf
error: 
Usage:
  naval_fate.sh ship new <name>...
  naval_fate.sh ship <name> move <x> <y> [--speed=<kn>]
  naval_fate.sh ship shoot <x> <y>
  naval_fate.sh mine (set|remove) <x> <y> [--moored|--drifting]
  naval_fate.sh -h | --help
  naval_fate.sh --version

Unit test:

I wrote a test in bats based on the rock_stdin_example.sh case, parsing the help string from comment.

See PR I will log for the code, which is derived from the docopts_help_string test - output is:

$ ./bats/bin/bats .
 ✓ docopt_auto_parse testing internal behavior
 ✓ docopt_auto_parse functionnal testing
 ✓ no source
 ✓ global eval
 ✓ docopts error
 ✓ --no-declare
 ✓ docopt_get_help_string
 ✗ docopt_get_help_string_with_options
   (in test file ./docopts.bats, line 58)
     `[[ ${#lines[@]} -eq 6 ]]' failed
 ✓ docopt_get_values
 ✓ docopt_get_eval_array
 ✓ docopt_get_raw_value
 ✓ docopt_print_ARGS

12 tests, 1 failure

$ cat log
---
--- output ---
Usage: rock [options] <argv>...

Options:
      --verbose  Generate verbose messages.
      --help     Show help options.
      --version  Print program version.
--- lines ---
Usage: rock [options] <argv>...
Options:
      --verbose  Generate verbose messages.
      --help     Show help options.
      --version  Print program version.
---
Line count = 5

The output from bats $output is correct, but the $lines array is missing the blank line before 'Options:'.

get_docopts.sh gets binaries from a fork

Hi,

I recently stated using the python version of docopt and was looking into using it for my bash scripts.
When inspecting the download helper I noticed that it retrieves the binaries from a fork, instead of the official repo

docopts/get_docopts.sh

Lines 10 to 12 in 75c2dfa

GIT_USER=Sylvain303
GIT_PROJECT=docopts
BASE_URL=https://github.com/$GIT_USER/$GIT_PROJECT/releases/download

This lines are a holdover from the script introduction on fc7c9bf
I do not suspect fowl play, but it looks wrong.

Thanks for the awesome tool.
Álvaro.

Generate getops string from docopt

I love docopt but there are certain scenarios where I can't leverage docopt for the parsing, but still use docopt for documenting a script.

In these scenarios, I frequently need to use getopts for actual option parsing. It would be awesome if one could generate the getopts string from docopt. (Or vice versa.)

This way I could generate the string and either paste it into my getopts usage, or at least compare and verify that my docopt is documenting correctly per my getopts string.

Of course, getopts doesn't support long flags. So attempting to generate getopts string from docopt which uses long flags would be an error.

Reactoring introduce new docopt grammar parser

More to come and to be edited in this issue / tracking discussion.

See grammar branch

The docopt parent project is stalled so mostly all parser improvement. I love parsing, as most of the couple of parser developer around the world. They are very few, search bison / yacc / GNU Lex / grammar generator / Abstract Syntax Tree and such topic.

I'm in the process of a total rewrite the grammar parser of docopt so removing dependencies of also stalled go-docopt lib.

The main goal is error handling while building the docopts definition. Error handling is difficult in parsing and should be done with care.

I did spend a couple of hundred hours experiencing grammar code generator for this purpose but: generator are not so well flexible on error handling and docopt grammar is quite complex to describe with standard tool.

So I decided, for fun too, to rewrite a grammar parser from scratch hand crafted!

More to come.

Bug in expansion of variable length parameters (when count of parameters == 0)

Description

docopts.go is expanding empty arrays to be a 1-element array with a single null/empty string element in

s = fmt.Sprintf("('%s')", strings.Join(arr_out[:],"' '"))

Details

OK, this one is a bit edge-case-y, but it causes an issue with the way bash expansion works. Specifically, docopts is not creating an empty array when a ... element is defined, but no parameters are given. Instead, it creates an array containing a single null element.

This gets confusing, because bash considers it an empty array (if you query the length of the array) as the element is null, but if you pass it using standard bash expansion, it will be expanded to an empty string which will confuse any downstream commands.

Test Case 1

Here is the test script (I tried to use the use case defined in testcases.docopt, but I could not trace down exactly why that specific test case is not failing here)

NOTE: You need two scripts to see the problem clearly :)

test1.sh: this just runs the basic test case which has the bug:

#!/bin/bash

#docopts --debug -h - : "$@" <<EOF
#Test script for ... in docopts
#Usage:
  #$0 [NAME [NAME ...]]
  #$0 -h | --help
#EOF

eval "$(docopts -h - : "$@" <<EOF
Test script for ... in docopts
Usage:
  $0 [NAME [NAME ...]]
  $0 -h | --help
EOF
)"

echo "NAME: Contains ${#NAME} elements"

./test2.sh "${NAME[@]}"

and test2.sh:

#!/bin/bash

echo "$0: Called with $# parameters"

And the results:

% ./test1.sh 1
NAME: Contains 1 elements
./test2.sh: Called with 1 parameters
% ./test1.sh 1 2
NAME: Contains 1 elements
./test2.sh: Called with 2 parameters
% ./test1.sh
NAME: Contains 0 elements
./test2.sh: Called with 1 parameters

As you can see:

  • The first call has 1 param, it gets passed as 1 param, no problem
  • The second case has 2 params, passed as 2, no problem
  • The third case has 0 params, but it is passed as 1.

Test Case 2: Seeing this in pure bash, without docopts

So, let's find the root cause: what does docopts output that bash doesn't handle well?

test3.sh:

#!/bin/bash

declare -a empty_array
empty_array=()

declare -a one_null_array
one_null_array=('')

echo "Empty array:"
./test2.sh "${empty_array[@]}"

echo "One null array:"
./test2.sh "${one_null_array[@]}"

And the result:

% ./test3.sh
Empty array:
./test2.sh: Called with 0 parameters
One null array:
./test2.sh: Called with 1 parameters

Conclusion:

Somehow, this is expanding the empty array once: can we change it so that it just emits a name=() instead of name=('') for this use case? (I need to learn more go :) )

s = fmt.Sprintf("('%s')", strings.Join(arr_out[:],"' '"))

Perhaps we could (maybe) move the ' into the Join rather than outside?

[RFC] Remove Dependency on Python

If I'm using bash, it's a strong indicator that I can't use Python or any other scripting language. The key use that I have for bash scripts is to automate existing manual tasks on servers that I can't change. I don't know how much work it would entail to port 'all the way' to bash. Conversely, if we want to replace getopt, then maybe we should provide a self-contained binary so that it's possible to download and execute it without help from the package manager, or at least without having to wrangle both the OS package manager AND the language package manager(s).

Thoughts?

embedded docopts.sh wrapper into docopts binary

Following #59 (Search "Sidebar -- docopts.sh entrypoint wrapper" heading)

We discussed how to embed docopts.sh wrapper into docopts binary itself. One of the purpose is to keep a single standalone binary. May be it could also open some new feature and or behavior. So lets explore.

Pros

  • both docopts and shell helper at the same place
  • coherent with example
  • could be also outputted as evaled content
  • could be stored in the $PATH too at user preference ex: docopts get-wrapper docopts.sh > $HOME/bin/docopts.sh

Cons

  • huge impact on eval if the code is also evaled at run time

Go sample code

package main

import (
  _ "embed"
  "fmt"
)

//go:embed docopts.sh                                                                                                                                
var docopts_sh string

func main() {
  fmt.Println(docopts_sh)
}

Go code ref

https://pkg.go.dev/embed
https://go.dev/src/fmt/print.go

golang/go#28822 - discussion about automatic handling NEWLINE

https://en.wikipedia.org/wiki/Newline#Representation (seems macos moved to \n)

from issue above: notepad seems windows 10 to support \n
May 8th, 2018 - https://devblogs.microsoft.com/commandline/extended-eol-in-notepad/

docopts API changes proposal

following #5

I had a look on the API proposed in the branch develop (See man ./docopts.1). Which is quite different from the current docopts API.

Old API (current)

eval "$(python3 $libexec/docopts -A args -V "$version" -h "$help" : "$@")"

if ${args[--do-something]} ; then
  run_some_code
fi

current API in branch develop, generating temporary files for each option on the filesystem

tmpdir=$(echo "$help" | python3 $libexec/docopts "$@")                                                        
if [ -e $tmpdir/--do-something ]; then
    echo "Option given with argument $(cat $tmpdir/--do-something)."
fi

I think about a new API, more like the python's library could be quite nice to have.

Something like the following code snippet, (to be completed…)
Specifying the associative array for $args and some shell centric behavior have to be considered, too.

#!/bin/bash
# sourcing the API providing some bash functions ie: docopt()
# still using the python parser
source docopts.sh

parsed=$(docopt -A args "$help_string" "$@" "$version" "$options_first")
eval "$parsed"

and may be some shell helpers too:

help_string=$(get_help_string $0)

array_opt=( $(get_docopt array "${args[--multiple-time]})" )

Please comment and suggest. I will develop and propose some versions.

You may also be tempted to say: "bash is not capable to handle simply the complexity of the JSON parsed structure behind docopt. Consider rewriting your shell script directly in python…"

[docopt.sh alternative] provide name mangling compatible for docopt.sh

Following #35: this is a twin issue with the project docopt.sh - twin issue andsens/docopt.sh#7

docopt.sh use global vars with or without prefix the non letter, number characters are converted to underscore (code here)

In order to improve compatibility we need to output compatible variables name from docopts

Prototype is here

Output code is here

Usage:

./docopts --docopt_sh -h "Usage: pipo new [--switch <value>]" : new --switch some_value

Outputs:

new=true
__switch=true
_value_='some_value'

package docopts

provide a debian package for docopts.

Other package will be added. Ask for it or contribute.

We need:

  • man page
  • other package requisites
  • tag a release

--debug flag not working as intended?

Seeing debug print strange output on OSX:

#!/usr/bin/env bash

eval "$(./docopts-osx --debug -h - : "$@" <<EOF
A script

Helpful commands to work with this project.

Usage:
  ./make admin COMMAND
EOF
)"

echo "$COMMAND"

Output I see

$ ./test.sh admin hi
./test.sh: line 13: --debug: command not found
./test.sh: line 14: --help: command not found
./test.sh: line 15: --no-declare: command not found
./test.sh: line 16: --no-help: command not found
./test.sh: line 17: --no-mangle: command not found
./test.sh: line 18: --options-first: command not found
./test.sh: line 19: --separator: command not found
./test.sh: eval: line 20: syntax error near unexpected token `newline'
./test.sh: eval: line 20: `           --version : <nil>'

I wanted to test using [--] since it wasn't working as I expected. But the debug output is not presenting something useful. If I remove the --debug flag I get:

$ ./test.sh admin hi
hi

Document that bash 3.2 on macOS won't work

I built and tried docopts on macOS, and found that the examples don't work - apparently because bash 4.x is required due to use of associative arrays.

If this is correct, would like to add something to README.md near the top saying that macOS is not supported due to bash 3.2, unless you upgrade bash to 4.x using Homebrew, and adjust shebang lines in scripts. (Apple won't upgrade to 4.x due to its policy on GPLv3.)

Example of errors, had this with several examples:

$ ./naval_fate.sh 
panic: "usage:" (case-insensitive) not found.

goroutine 1 [running]:
main.main()
	/Users/richard/gocode/src/github.com/docopt/docopts/docopts.go:423 +0xd87
../docopts.sh: line 127: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
../docopts.sh: line 128: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
docopt_print_ARGS => ARGS

Alternative implementation

Hi there. I needed a way to parse arguments in my bash scripts without external dependencies, so I wrote docopt.sh. It's an argument parser generator for docopt. I see it as an alternative to your current implementation and was wondering how I would go about getting the repo transferred to the docopt org?
I wrote an email to Vladimir, but he hasn't answered.

Only the line containing the "Usage:" identifier is parsed on bash 4.4.12

Only the line containing the "Usage:" identifier is parsed on Debian GNU/Linux 9 (stretch)

GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)

It works fine on 4.4.20 (Ubuntu 18.04.4).

I was also seeing the following on 4.4.12

goroutine 1 [running]:
main.main()
	/tmp/docopts_v0.6.3-rc2.5349/docopts.go:458 +0xfc7
docopt_print_ARGS -G => ARGS_*

but I fixed this by pulling the first line of usage back up to the e.g.

# Usage: command1 arg1 arg2

and not

# Usage: 
#  script command1 arg1 arg2

Either will work on 4.4.20. I am using

PATH=../..:$PATH
source ~/docopts.sh --auto -G "$@"

The workaround is to delete all usage lines before the one that is required at the time.

New maintainer needed

I started docopts a year and a half ago in order to better maintain the many shell scripts I wrote for work, but for a long time now I haven't worked there nor with shell scripts at all, so my interest has been waning. As such, I'm going to retire as docopts maintainer.

Maintainership isn't really anything formal in the docopt organization, of course, since all members can commit in any subproject anyway, but I've also got solo admin access to docopts's PyPI page, which is something I should probably turn over to someone else if I'm going away. If no volunteers step up immediately, I suppose @halst would be okay?

get_docopts.sh downloads 32-bit build instead of 64-bit on macOS Catalina

Hi.

I'm trying to use docopts on a side project, so I've cloned the repo and executed get_docopts.sh to download the build. Unfortunately it downloads the 32-bit build.

I noticed arch command is used in the script, which returns me i386. This mismatch happens because arch doesn't work in the same way on macOS as it's mentioned here: https://stackoverflow.com/questions/12763296/os-x-arch-command-incorrect

Could be fixed checking uname -m command and comparing with ARCH variable when macOS is detected.

docopt_get_values: doesn't handle arguments with whitespaces properly

This is not what I was expecting:

source "$(command -v docopts).sh"
declare -A args
args['FILE,#']=2
args['FILE,0']=somefile1
args['FILE,1']='some file with space inside'

array=( $(docopt_get_values args FILE) )

if [[ "${array[1]}" != 'some file with space inside' ]] ; then
	echo "element #1 is not properly set"
fi

if [[ "${array[*]}" == 'somefile1 some file with space inside' ]] ; then
	echo "5 elements - 1 per word"
fi

There is no indication it should not work in docs or comments

Failing test n. 104

Hello,

(update: this referes to the Python-based version docopts 0.6.1+fix)

downloading docopts and running:

./language_agnostic_tester.py ./testee.sh 

I obtain this:

================================= 104: FAILED =================================
r"""Naval Fate.

Usage:
  prog ship new <name>...
  prog ship [<name>] move <x> <y> [--speed=<kn>]
  prog ship shoot <x> <y>
  prog mine (set|remove) <x> <y> [--moored|--drifting]
  prog -h | --help
  prog --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --speed=<kn>  Speed in knots [default: 10].
  --moored      Mored (anchored) mine.
  --drifting    Drifting mine.

"""
$ prog ship Guardian move 150 300 --speed=20

result> {"--version": false,
"<y>": "300",
"--moored": false,
"--help": false,
"--speed": 20,
"shoot": false,
"remove": false,
"<x>": "150",
"ship": true,
"<name>": ["Guardian"],
"move": true,
"--drifting": false,
"new": false,
"set": false,
"mine": false}

expect> {"--drifting": false,
 "--help": false,
 "--moored": false,
 "--speed": "20",
 "--version": false,
 "<name>": ["Guardian"],
 "<x>": "150",
 "<y>": "300",
 "mine": false,
 "move": true,
 "new": false,
 "remove": false,
 "set": false,
 "ship": true,
 "shoot": false}
================================== 163 / 164 ==================================

the results and expected differ for the --speed parameter which is 20 in one case and "20" in the other.

Here's my Python version:

$ python --version
Python 2.7.8

and here's my docopt version:

$ python                                                                                                                                                                 
Python 2.7.8 (default, Oct 20 2014, 15:05:19) 
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docopt
>>> docopt
<module 'docopt' from '/usr/local/lib/python2.7/dist-packages/docopt.pyc'>
>>> docopt.__version__
'0.6.2'

My docopts version is docopts 0.6.1+fix

Cristian

Rock example with grep and cut is broken

Hi. I've been banging my head on this for about an hour. This is not my first attempt at getting docopt working on a stupid shell script. No matter what I do, the eval docopts line thinks -h is one of the args and spits out a help message.

I copied

#!/bin/sh                                                                                 
## rock 0.1.0
## Copyright (C) 200X Thomas Light
## License RIT (Robot Institute of Technology)
## This is free software: you are free to change and redistribute it.
## There is NO WARRANTY, to the extent permitted by law.

### Usage: rock [options] <argv>...
###
###       --help     Show help options.
###       --version  Print program version.

help=$(grep "^### " "$0" | cut -c 5-)
version=$(grep "^## "  "$0" | cut -c 4-)
eval "$(docopts -h "$help" -V "$version" : "$@")"

for arg in "${argv[@]}"; do
      echo "$arg"
done

from the example. It broke in the same way. When I switched to the heredoc example, it worked without issue.

The future of docopts

There should absolutely be a better command line argument parser in the shell scripting world than getopt(s), but I'm increasingly unsure if docopts is it. It uses an ugly and convoluted access syntax and either pollutes the environment with name-mangled variables or fake nested arrays. Granted, shell scripting usually isn't very pretty, but I'd like to try something different, and I'd like you to tell me if it's too different.

I've been thinking about the following possibilities:

  1. #!/usr/local/bin/docopts /bin/sh. That is, instead of passing a docstring to docopts, one passes a path to a script file to docopts, which then extracts the docstring from it, uses it to parse the arguments passed to the script, stores them in environment variables, and calls the original script with the arguments already parsed. This would essentially reduce argument-parsing boilerplate to zero, but might be an even uglier hack than what it is replacing. A standard comment prefix for help and version messages would also have to be dictated, or changeable through options.
  2. Rewrite docopts in C as a shell extension, importable via enable -f /path/to/docopts.so. Builtins can manipulate the environment as they wish, so eval and $@ would no longer be necessary in the invocation.

Neither of them, however, addresses the shell's ill-suitedness for docopt's standard mode of operations: returning an associative array mapping argument names to their parsed values. Ideally I'd like to do without obscure or faked features, even if it means cutting down on docopt features, but I'm not sure how to go about doing this. Thoughts?

Repeated options (-vvv) don't give a count value

I was trying to get repeated -v arguments working to increase level of verbosity (as used by ssh, rsync, ansible, etc).

This seems to be supported by docopt, based on this try.docopt.org test, giving a value of 2 for the v option in output - but the example below doesn't work in docopt/docopts 0.6.3:

#  mywrapper [-h|--help] [options] [-v|-vv|-vvv|-vvvv|-vvvvv]
# 
# Options:
#   -v, --verbose                       Show verbose Ansible output
#   -vv                                 Show verbose Ansible output
#   -vvv                                Show verbose Ansible output
#   -vvvv                               Show verbose Ansible output
#   -vvvvv                              Show verbose Ansible output

Any use of -vv for example gives a usage error.

I am currently having to use options like --v3 as a workaround. Using --v=3 would be OK but not as pleasant for the user as repeating -v to get more verbose.

Any suggestions on how to do this?

Create Homebrew tap?

Problem

Installation currently requires not just downloading pre-built binaries via GitHub Releases, but also cloning the repo or otherwise downloading the docopts.sh helper.

Suggested Solution

Distributing via a package manager could make it much easier to get started with docopts, especially for Shell projects that don't have a language-specific package manager to use.

On macOS at least, Homebrew is the defacto default package manager (Brew also works on Linux, though there are better package managers available there). Can create a repo under the docopt organization, homebrew-docopt which will serve as the Homebrew Tap. Taps are just git repos (with Ruby code), so it's relatively straightforward in that sense.

An example of a simple Homebrew tap is Instrumenta's (creator of Conftest, kubeval, etc).
As you can see there, a simple Formula can just reference a GitHub Release, acting as a simple wrapper around the existing pre-built binaries.

Contributing

Would be happy to contribute building this or even build a standalone repo myself and transfer it to the docopt organization if that is acceptable.

Misc

I used docopts at my last job and it helped a ton with both documentation and arg/option parsing, but installation was my team's main gripe with it. Awesome tool that I would love to make easier to install!

docopts adds the `--` token to the position arguments

Howdy!

I think I've got a bug, or maybe it's a feature request.

I've got a hypothetical docstring like so

# Usage
#   search --directory=<string> <command>...

and I'm trying to run the <command>... grep -A4 some-package package.json

The trouble is, if I invoke my script without the -- I get

$ search --directory foo grep -A4 some-package package.json
error:
Usage:
  search --directory=<string> <command>...

and if I add the -- token so that the -A4 isn't parsed by docopts then I get

$ search --directory foo -- grep -A4 some-package package.json
docopt_print_ARGS => ARGS
           --directory = foo
         <command>,4 = package.json
         <command>,0 = --
         <command>,1 = grep
         <command>,2 = -A4
         <command>,3 = some-package
         <command>,# = 5

so it appears the -- is incorrectly being added as a position argument, in addition to being used as the no more arguments token.

This would be pretty gnarly to work around in the shell script, as I'd have to handle both the normal case where there is no -- and the exceptional case where -- is the first position argument. I think it's more natural to just drop the -- as a parsed argument.

What do you think? Would this break some backwards compatibility?

[FR] return X instead of exit X

Hi

Note that due to the above, docopts can't be used to parse shell function arguments: exit(1) quits the entire interpreter, not just the current function.

Would be really nice to add an option to use "return" instead of "exit" to be able to use docopts inside function too.

Regards,

Separating different positional arguments

I'm trying to separate positional arguments from extra arguments, like this:

#!/usr/bin/env bash

help="
  Usage:
    cli [<args>...] [--] [<extra-args>...] 
"

docopts --no-declare -A args -h "$help" : "$@"

But running ./cli.sh pos -- extra will print this:

args['--']=false
args['<args>,0']='pos'
args['<args>,1']='--'
args['<args>,2']='extra'
args['<args>,#']=3
args['<extra-args>,#']=0

All of the positional arguments are consumed by <args>. How do I separate them?

provide a simpler case $ACTION API through docopts

use case show_env is listed and not trigered, but create_target_group is remove from action list, but still in the if .. elif .. fi

WARNING: this bash eval at true

v=''
if $v ; then echo pipo; fi
#  will output pipo

example cli (snipet not tested)

# Usage:
#  ./run_migration.sh init
#  ./run_migration.sh add DESCRIPTION MIGRATION_FILE [--target_group=TARGET_GROUP]
#  ./run_migration.sh list
#  ./run_migration.sh run MIGRATION_JOBID
#  ./run_migration.sh delete MIGRATION_JOBID
#  ./run_migration.sh view MIGRATION_JOBID
#  ./run_migration.sh list_target_groups
#  ./run_migration.sh list_available_target
#  ./run_migration.sh list_databases [--server=SERVER_NAME] [--join]
#  ./run_migration.sh show_env
#  ./run_migration.sh -h
#

SCRIPT_DIR=$(dirname $0)
PATH=$SCRIPT_DIR:$PATH
# auto parse the script header and export ${ARGS[]} mapped argument
# docopts do all the magic parsing argument as defined in the doc header.
source docopts.sh --auto "$@"

## ======================================== main switch for arguments
if ${ARGS[add]}
then
  add_migration "${ARGS[DESCRIPTION]}" "${ARGS[MIGRATION_FILE]}" "${ARGS[--target_group]}"
elif ${ARGS[run]}
then
    if exec_migration_job ${ARGS[MIGRATION_JOBID]}
    then
      echo "migration in progress"
      exit 0
    fi
elif ${ARGS[list]}
then
  list_migration
elif ${ARGS[delete]}
then
  delete_migration_job "${ARGS[MIGRATION_JOBID]}"
elif ${ARGS[view]}
then
  view_migration "${ARGS[MIGRATION_JOBID]}"
elif ${ARGS[list_target_groups]}
then
  list_target_groups
elif ${ARGS[create_target_group]}
then
  create_target_group "${ARGS[TARGET_GROUP]}" "${ARGS[SERVER_NAME]}" DATABASE
elif ${ARGS[list_databases]}
then
  list_databases
elif ${ARGS[list_available_target]}
then
  list_available_target
else
  echo "error: unknown action"
fi 

Could we provide something like:

case ${ARGS[docopts_ACTIONS]} in
   add)
    ;;
   run)
    ;;
   list)
    ;;
   *)
    ;;
esac

get_docopts.sh does not support macOS ARM

It is due to the pre-built binaries don't have a "darwin" and "arm", I think.

Since M1 macs are out for a while now, do you think the pre-built binary releases can support a new "darwin" "arm" download? Thanks.

status of bats tests

Hi Sylvain,

I've modified the shebangs in my clone to /usr/bin/env, and installed a bash4 (i cannot neither confirm or deny if asked if my standard shell is ksh93)

I then also did that to the helpers in the tests/ directory that are there for bats.
Currently I still get a few failures and you could help me a lot by letting me know if they're only on my end.

utopia:tests floh$ bats .
 ✗ docopt_auto_parse testing internal behavior
   (in test file ./docopts-auto.bats, line 39)
     `[[ $status == 1 ]]' failed
   ./tmp-docopt_auto_parse.sh
   panic: "usage:" (case-insensitive) not found.
   
   goroutine 1 [running]:
   main.main()
   	/Users/floh/golang/src/github.com/Sylvain303/docopts/docopts.go:423 +0xd73
   status=2
 ✗ docopt_auto_parse functionnal testing
   (in test file ./docopts-auto.bats, line 68)
     `[[ "$output" == prout ]]' failed
   ./tmp-docopt_auto_parse.sh
 ✓ no source
 ✓ global eval
 ✓ docopts error
 ✓ --no-declare
 ✗ docopt_get_help_string
   (in test file ./docopts.bats, line 24)
     `[[ "${lines[0]}" =~ $regexp ]]' failed
 ✓ docopt_get_values
 ✓ docopt_get_eval_array
 ✓ docopt_get_raw_value
 ✓ docopt_print_ARGS

11 tests, 3 failures

They seem to occur in standard comparisons. I'll try on a Linux box when I got time again.
If those errors are normal, I'd love to know so I don't hunt a phantom. :)

docopts can't be used for functions

Because docopts provides exit calls, using it in a function will exit the (usually interactive) shell.

I don't think there's a good way around this; you must use exit in a stand-alone script, and you need to use return in a function. Realistically, this probably means we just need a warning in the README.

Test 24 docopt_get_values fails.

Applying #65 on top of latest master 62aed3d4cb02f36864ace03ecb89f8a200e311ca, as I am unable to build otherwise:

not ok 24 docopt_get_values
# (in test file ./docopts.bats, line 120)
#   `[[ ${#array[@]} -eq 3 ]]' failed
# array count: 1

Possibly related to #70? I'm not entirely sure.

Terse error message | panic: no fields found in usage (perhaps a spacing error)

The error message given is too terse for me.

Could you elaborate when can I get this error message?

ansible@iinfra2-test:/tmp$ ./create_workload_user -h
panic: no fields found in usage (perhaps a spacing error).

goroutine 1 [running]:
main.main()
	/tmp/docopts_v0.6.3-rc2.5349/docopts.go:458 +0xfc7
./create_workload_user: line 21: <workload_user>: syntax error: operand expected (error token is "<workload_user>")
./create_workload_user: line 23: user: unbound variable
ansible@iinfra2-test:/tmp$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
ansible@iinfra2-test:/tmp$ docopts --version
docopts v0.6.3-rc2 commit 651ff2c built at 2020-04-05T05:13:14Z
built from: go version go1.14.1 linux/amd64
Copyright (C) 2013 Vladimir Keleshev, Lari Rasku.
Copyleft (Ɔ)  2019 Sylvain Viart (golang version).
License MIT <http://opensource.org/licenses/MIT>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note, that this works on another machine (with other version of bash)

~/infra/workload-manager on  master! ⌚ 18:53:56
$ ./create_workload_user -h
Usage:
  create_workload_user -h | --help
  create_workload_user
  create_workload_user [--provider=<provider>] <workload_user>

Options:
  --provider=<provider>  Provider used, valid choices are vagrant and docker [default: vagrant]

~/infra/workload-manager on  master! ⌚ 18:54:04
$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

~/infra/workload-manager on  master! ⌚ 18:54:15
$ docopts --version
docopts v0.6.3-rc2 commit 651ff2c built at 2020-04-05T05:13:14Z
built from: go version go1.14.1 linux/amd64
Copyright (C) 2013 Vladimir Keleshev, Lari Rasku.
Copyleft (Ɔ)  2019 Sylvain Viart (golang version).
License MIT <http://opensource.org/licenses/MIT>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Relevant script part:

#!/usr/bin/env bash

set -o errexit -o pipefail -o noclobber -o nounset
shopt -s nullglob

# Usage:
#   create_workload_user -h | --help
#   create_workload_user
#   create_workload_user [--provider=<provider>] <workload_user>
#
# Options:
#   --provider=<provider>  Provider used, valid choices are vagrant and docker [default: vagrant]
#

source docopts.sh

usage=$(docopt_get_help_string "$0")
eval "$(docopts -A ARGS -h "$usage" : "$@")"

get_docopts.sh fails with "unrecognized option '--ignore-missing'"

On my macOS, it works; but on my linux, get_docopts.sh (from script) fails with:

Saving to: ‘docopts_linux_amd64’

100%[==================================================================================================================================================================================================================================================================================================================================>] 1,949,696   --.-K/s   in 0.04s

2021-11-19 14:51:33 (41.8 MB/s) - ‘docopts_linux_amd64’ saved [1949696/1949696]

docopts_linux_amd64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
verifying sha256sum signature from https://github.com/docopt/docopts/releases/download/v0.6.3-rc2/sha256sum.txt ...
sha256sum: unrecognized option '--ignore-missing'
Try 'sha256sum --help' for more information.
› sha256sum --help
Usage: sha256sum [OPTION]... [FILE]...
Print or check SHA256 (256-bit) checksums.
With no FILE, or when FILE is -, read standard input.

  -b, --binary         read in binary mode
  -c, --check          read SHA256 sums from the FILEs and check them
      --tag            create a BSD-style checksum
  -t, --text           read in text mode (default)
  Note: There is no difference between binary and text mode option on GNU system.

The following four options are useful only when verifying checksums:
      --quiet          don't print OK for each successfully verified file
      --status         don't output anything, status code shows success
      --strict         exit non-zero for improperly formatted checksum lines
  -w, --warn           warn about improperly formatted checksum lines

      --help     display this help and exit
      --version  output version information and exit

The sums are computed as described in FIPS-180-2.  When checking, the input
should be a former output of this program.  The default mode is to print
a line with checksum, a character indicating input mode ('*' for binary,
space for text), and name for each FILE.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'sha256sum invocation'
› sha256sum --version
sha256sum (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Ulrich Drepper, Scott Miller, and David Madore.
› uname -a
Linux host.redacted.com 4.14.123-111.109.amzn2.x86_64 #1 SMP Mon Jun 10 19:37:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

v0.6.4-with-no-mangle-double-dash released pending

I've build a new version of docopts v0.6.4-with-no-mangle-double-dash

release to github is pending, some tools are broken https://github.com/opensource-expert/deploy.sh


This is a bug fix release.

features changes:

  • fix error refusing mangling double dash in global mode [#52]
  • still refuse to mangle single dash [-] in global mode (not compatible with v0.6.1)
  • now can mangle single-dash and double-dash in -G mode
  • fix output bash empty array #53

internal changes:

  • use Go 1.17.1 for compiling
  • language_agnostic_tester.py re-write for python3
  • sort argument key in Print_bash_args() Print_bash_global()
  • sort input keys in docopts_test.go
  • add PR #52 test to testcases.docopt
  • completed developper's documentation
  • #52 ignore [--] double-dash option in Print_bash_global()
  • reformat of Go code with gofmt indent change Space ==> Tab
  • add tests/functional_tests_docopts.bats

Empty error message when launching script without mandatory argument

With the latest docopts-go build:

#!/usr/bin/env bash
# file: atest.sh

arg=''

eval "$(./docopts -V - -h - : "$@" <<EOF
Usage: atest.sh <arg>
       atest.sh ( -h | --help )
       atest.sh ( -V | --version )

      arg				An argument.

Options:
      -h, --help        Show this help message and exits.
      -V, --version     Print version and copyright information.
----
atest 0.1.0
EOF
)"

echo "$arg"

If I launch the script without the mandatory argument no error message is shown:

$ ./atest.
error: 
Usage: atest.sh <arg>
       atest.sh ( -h | --help )
       atest.sh ( -V | --version )

travis bats test are failing macOS

The bats tests are currently failing on macOS, probably some GNU tools not working the same on apple's version.

build_doc.sh is a Proof of Concept (PoC), an helper to write README.md.

As a PoC I may change this helper, and it is used only for helping developer to produce the README.

  • skip travis test for macOS on build_doc.sh
  • add test for get_docopts.sh (following #37)
  • take some decision about build_doc.sh (See also markdown ToC producer)

docopts.sh: line 14: type: write error: Broken pipe

When running tests with the latest build of docopts-go:

./language_agnostic_tester.py ./testee.sh

I get results like this:

================================= 6: BAD JSON =================================
result> ./docopts.sh: line 14: type: write error: Broken pipe
{"--all": false}

expect> {"--all": false}

The full log is attached here: test.log, I have seen that running the command multuple times the tests who fail are different. Sometimes I have that all tests pass.

My bash version is GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.