cli icon indicating copy to clipboard operation
cli copied to clipboard

IllegalArgumentException when optional flags are ommitted and additional args are passed to bb.cli.exec/main

Open felixdo opened this issue 1 year ago • 1 comments

parse-exec-opts throws an IllegalArgumentException in the following case:

(ns fs123.test (:require [babashka.cli :as cli] [babashka.cli.exec]))

(defn test
  {:org.babashka/cli
   {:spec
     {:flag {:coerce :boolean :default true} }
    :args->opts [:args2opts]}}
  [what] what)

(babashka.cli.exec/main "fs123.test" "test-me" "my-arg")

Originating discussion from slack.

felixdo avatar Aug 23 '24 19:08 felixdo

parse-commands is used to resolve the target function, for which at max 2 args should be consumed, that's why the cond only handles 0,1,2. The question is, what should we do with the remaining positional arguments? If we just "forget them", wouldnt be good.

felixdo avatar Aug 23 '24 19:08 felixdo