rremizov / clj-argparse

A convenience wrapper around org.clojure/tools.cli

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clj-argparse

A convenience wrapper around org.clojure/tools.cli

Clojars Project

Usage

(ns user (:require [clj-argparse.core :as argparse]))

(argparse/defclispec cli-spec
  (argparse/option ["-t" "--test" "Option description"])
  (argparse/subcommand "subcommand" "Subcommand description")
  (argparse/argument "subcommand" "first-arg"
                     "Positional argument description")
  (argparse/option "subcommand" ["-o" "--option" "Option description"]))

(argparse/parse cli-spec ["-t" "subcommand" "arg-value" "--option"])
;; =>
;; {"default"    {:options {:test true} :arguments {}}
;;  "subcommand" {:options {:option true}
;;                :arguments {"first-arg" "arg-value"}}}

(argparse/defclispec cli-spec
  (argparse/option ["-o" "--option" "Option description"])
  (argparse/argument "argument-name" "Positional argument description"))

(argparse/parse cli-spec ["-h"])
;; =>
;; Positional arguments:
;;    argument-name          Positional argument description
;;
;; Optional arguments:
;;   -h, --help    Print help
;;   -o, --option  Option description

License

Distributed under the Eclipse Public License

About

A convenience wrapper around org.clojure/tools.cli

License:Eclipse Public License 1.0


Languages

Language:Clojure 100.0%