nubank / docopt.clj Goto Github PK
View Code? Open in Web Editor NEWClojure implementation of the docopt description language
Home Page: http://docopt.org/
License: MIT License
Clojure implementation of the docopt description language
Home Page: http://docopt.org/
License: MIT License
Hi, first of all, thanks for all your work on this implementation!
I have a question, given the code example below:
naval_fate.clj --nonsense
Returns the usage as expected.
naval_fate.clj -h
or naval_fate.clj --help
This only returns the usage if I uncomment the (when (arg-map "--help")
or remove the help from usage and options documentation, otherwise, it will execute the (println arg-map)
#!/usr/bin/env bb
(require '[babashka.classpath :refer [add-classpath]]
'[clojure.java.shell :refer [sh]])
(def docopt-dep '{:deps {dev.nubank/docopt {:mvn/version "0.6.1-fix7"}}})
(def cp (:out (sh "clojure" "-Spath" "-Sdeps" (str docopt-dep))))
(add-classpath cp)
(require '[docopt.core :as docopt])
(def usage "Naval Fate.
Usage:
naval_fate ship new <name>
naval_fate ship <name> move <lat> <long> [--speed=<kn>]
naval_fate mine (set|remove) <lat> <long> [--moored|--drifting]
naval_fate -h | --help
naval_fate --version
Options:
-h --help Show this screen.
--version Show version.
--speed=<kn> Speed in knots [default: 10].
--moored Moored (anchored) mine.
--drifting Drifting mine.")
(docopt/docopt
usage
*command-line-args*
(fn [arg-map]
;(when (arg-map "--help")
;(println usage)
;(System/exit 0))
(println arg-map)))
I'm doing something wrong or this manual handling is expected?
Hi,
I'm using docopt.clj via babashka to build a CLI app and I want to pass multiple string options, some of which might contain spaces.
When I add these options with quotes, the parser fails.
Example:
(ns helmer)
(def usage "Helmer Simpson - Docker Swarm template system. Because I can't use helm.
Merge yml templates with variables to produce stack files.
Usage:
helmer.clj render [-f=<values>...] [--set=<entry>...] [-o=<output>] [-V] <template>
helmer.clj -h | --help
helmer.clj --version
Options:
-h --help Show this screen.
--version Show version.
-V --verbose Print detailed information about execution.
-o=<output> --output=<output> Write result to <output> file.
-f=<values> --values=<values> Load file as values.
--set=<entry> Set variables via command line.")
(docopt/docopt usage
*command-line-args*
(fn [arg-map] (clojure.pprint/pprint arg-map)))
I get this:
./script/helmer.clj render dev/stack.tpl.yml -f "file with space in it.txt" --set my.val="with space"
Helmer Simpson - Docker Swarm template system. Because I can't use helm.
Merge yml templates with variables to produce stack files.
Usage:
helmer.clj render [-f=<values>...] [--set=<entry>...] [-o=<output>] [-V] <template>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.