l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
360 stars 28 forks source link

example not executing as documented. #138

Closed drewverlee closed 2 years ago

drewverlee commented 3 years ago

version

0.4.3

platform

[ Please specify which platform you are using clj-matic on, like JVM or JS and which version ]

JVM

[ Please provide a short and to the point description of the problem ]

examples/toycalc-nested.clj doesn't work as documented.

[ Please provide a minimal working reproduction of the problem ]

➜  cli-matic git:(master) ✗ ./examples/toycalc-nested.clj -base 16 subc sub --a 16 --b 3
** ERROR: **
Global option error: Unknown option: "-b"
Unknown option: "-a"
Unknown option: "-s"
Unknown option: "-e"

NAME:
 toycalc - A command-line toy calculator

USAGE:
 toycalc [global-options] command [command options] [arguments...]

VERSION:
 0.0.1

COMMANDS:
   add                  Adds two numbers together
   subc                 Subtracts parameter B from A

GLOBAL OPTIONS:
       --base N  10  The number base for output
   -?, --help

[ What is the behavior you expected to see from clj-matic? Please provide a minimal working example ]

from the docs the output should be d

[ What is the actual behavior of clj-matic? ]

Actual behavior is an error for unknown options.

timgilbert commented 2 years ago

I think the problem here is that you're passing a CLI of -base instead of --base (note the two hyphens). If I run this with --base I get the expected result:

❯ ./examples/toycalc-nested.clj --base 16 subc sub --a 16 --b 3
WARNING: Implicit use of clojure.main with options is deprecated, use -M
d