Skip to content

:default values for :jsonfile options do not parse files #146

@timgilbert

Description

@timgilbert

Edit: this behavior also holds true for :ednfile options; I didn't test :yamlfile but I imagine it's the same there.

version

0.4.3

platform

JVM 11

problem

:default values for :jsonfile options do not parse files

repro

(require '[cli-matic.core :as c])
;; => nil

;; Using a :jsonfile option the normal way
;; test.json consists of {"abc": 1}

(c/run-cmd* {:command "foo"
             :opts    [{:option "file"
                        :type :jsonfile
                        :default "test.json"}]
             :runs    (fn [args] (clojure.pprint/pprint args))}
            ["--file" "test.json"])

;; Results: 
{:file {"abc" 1}, :_arguments []}

;; Trying to use a default value to specify the filename if the user didn't specify
(c/run-cmd* {:command "foo"
             :opts    [{:option "file"
                        :type :jsonfile
                        :default "test.json"}]
             :runs    (fn [args] (clojure.pprint/pprint args))}
            [])

;; Results:
{:file "test.json", :_arguments []}

expected behavior

clj-matic should parse test.json and return the parsed results

actual behavior

clj-matic just gives me the default filename

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions