[TCLI-3] Change contract to provide access to banner on parse error Created: 09/Feb/13 Updated: 08/Mar/13 |
|
| Status: | Open |
| Project: | tools.cli |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Philip Aston | Assignee: | Gareth Jones |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
If a user provides an invalid option, most applications would want to display the banner. tools.cli throws an Exception with minimal information, and (banner-for) is marked private. The exception could be replaced with one that provides access to the banner, but I think it would be better (easier to use, more idiomatic?) to change the contract so that the banner is always returned. Given the exception string is also useful, perhaps change cli to return a map with keys [:options :extra-args :banner :parse-failure]? |
| Comments |
| Comment by Gunnar Völkel [ 08/Mar/13 4:19 AM ] |
|
I agree with the reporter. Throwing an exception for invalid arguments ("[...] is not a valid argument") is not appropriate since you usually want to display that error message along with the banner. |
[TCLI-2] Allow caller-supplied parse-fn Created: 11/Nov/12 Updated: 11/Apr/13 |
|
| Status: | Open |
| Project: | tools.cli |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Major |
| Reporter: | Pierre-Yves Ritschard | Assignee: | Gareth Jones |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | enhancement | ||
| Attachments: |
|
| Description |
|
As for :parse-fn, a function can be supplied, this PR: https://github.com/clojure/tools.cli/pull/11 |
| Comments |
| Comment by Andy Fingerhut [ 11/Nov/12 12:38 PM ] |
|
Pierre-Yves, there are instructions for creating patches under the headings "Development" and "Adding patches" on this page: http://dev.clojure.org/display/design/JIRA+workflow Submissions to this module do require the author to sign a CA. Instructions here: http://clojure.org/contributing |
| Comment by Pierre-Yves Ritschard [ 11/Apr/13 9:48 AM ] |
|
Suggested Patch |
| Comment by Pierre-Yves Ritschard [ 11/Apr/13 9:48 AM ] |
|
Hello, now that I'm a registered contributor, I attached a file as suggested in the workflow wiki |
[TCLI-1] Do not include keys when no value provided and no :default Created: 18/May/12 Updated: 24/Aug/12 Resolved: 24/Aug/12 |
|
| Status: | Closed |
| Project: | tools.cli |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Stuart Sierra | Assignee: | Stuart Sierra |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Patch: | Code and Test |
| Description |
|
I was trying to use tools.cli in conjunction with a configuration map This didn't work because tools.cli always uses a default value of Example before the patch: (def my-defaults
{:foo 1})
(merge my-defaults
(first (clojure.tools.cli/cli
[] ; no arguments given
["--foo"]))) ; no default specified
;;=> {:foo nil}
This enhancement modifies tools.cli to completely omit arguments which After the patch, the above example returns: ;;=> {:foo 1}
|
| Comments |
| Comment by Stuart Sierra [ 20/Jul/12 7:41 AM ] |
|
New patch file 0002 fixes syntax error in the previous patch; updated description to show correct results. |
| Comment by Stuart Sierra [ 24/Aug/12 8:31 AM ] |
|
Patch applied in commit https://github.com/clojure/tools.cli/commit/f9d92395cb788dd08cb144035a9d5fd8706d10b5 |