Skip to content

rremizov/clj-argparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published