Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

[Issue] Optional arguments in final array #260

Open
gtrabanco opened this issue Jul 15, 2021 · 1 comment
Open

[Issue] Optional arguments in final array #260

gtrabanco opened this issue Jul 15, 2021 · 1 comment

Comments

@gtrabanco
Copy link

Describe the bug
Found a bug with optional arguments and final array.

To Reproduce
Define a docopt like this one in a shell script:

#!/usr/bin/env bash
##? Install a package
##?
##? Usage:
##?    $0 [--pkgmgr <package_manager>] <packages_names>...
eval "$(docpars -h "$(grep "^##?" "$0" | cut -c 5-)" : "$@")"
echo "pkgmgr: $pkgmgr"
echo "package_manager: $package_manager"
echo "packages: ${package_names[*]}"
echo

Call the script with arguments:

--pkgmgr cargo docpars deno bashdoc

Show output:

pkgmgr: true
package_manager: cargo
packages: docpars deno bashdoc

Fail 1

All went well, but if you call with arguments:

docpars deno bashdoc

Will show you:

pkgmgr: false
package_manager: docpars
packages: deno bashdoc

The docpars value is in package_manager and not in the final array.

Fail 2

And finally if you call the script with arguments:

--pkgmgr cargo

It will output:

pkgmgr: true
package_manager:
packages: cargo

cargo is in packages_names instead of package_manager.

Expected behavior

Case fail 1

pkgmgr: false
package_manager:
packages: docpars deno bashdoc

Case fail 2

pkgmgr: true
package_manager: cargo
packages: 

Screenshots
Screenshot 2021-07-14 at 16 58 16

Versions:

  • OS: macos 11.4 Big Sur
  • Shell Version [replace this text with the output of sh --version]
> $SHELL --version
zsh 5.8 (x86_64-apple-darwin20.0)
  • docpars: v0.2.0

Additional context
The script is dot package add of my Dotly fork, see it here:

@gtrabanco
Copy link
Author

This was reported also to docpars which is the tool I have used, but the issue is in this library.

denisidoro/docpars#4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant