We're updating the issue view to help you get more done. 

Do not include keys when no value provided and no :default

Description

I was trying to use tools.cli in conjunction with a configuration map
loaded from a file, and use clojure.core/merge to combine the results.

This didn't work because tools.cli always uses a default value of
nil, even when no default value is specified. The nil always
overrides defaults from another source.

Example before the patch:

1 2 3 4 5 6 7 8 (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
have no default specified and no value given on the command line.

After the patch, the above example returns:

1 ;;=> {:foo 1}

Environment

None

Status

Assignee

Stuart Sierra

Reporter

Stuart Sierra

Labels

None

Approval

None

Patch

Code and Test

Priority

Minor