Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: Optional arguments and final array #4

Closed
gtrabanco opened this issue Jul 14, 2021 · 3 comments
Closed

Issue: Optional arguments and final array #4

gtrabanco opened this issue Jul 14, 2021 · 3 comments
Labels
bug Something isn't working

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 gtrabanco added the bug Something isn't working label Jul 14, 2021
@welcome
Copy link

welcome bot commented Jul 14, 2021

Thanks for opening your first issue here! In case you're facing a bug, please update docpars to the latest version first. Maybe the bug is already solved! :)

@denisidoro
Copy link
Owner

Thanks for reporting this!

This repository is just a thin wrapper between the rust library and bash. Unfortunately I'm not familiar with the docopt parsing algorithm.

Would you mind opening the same issue but in https://github.com/docopt/docopt.rs?

I'll gladly bump the library and release a new version of docpars whenever there's a new update.

@gtrabanco
Copy link
Author

Yes I supposed you would reply that. I decided to post it here anyway because that project seems unmanteinanced as README says 😅

I will post it there anyway.

Thanks anyway @denisidoro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants