GithubHelp home page GithubHelp logo

nubank / docopt.clj Goto Github PK

View Code? Open in Web Editor NEW
77.0 77.0 3.0 113 KB

Clojure implementation of the docopt description language

Home Page: http://docopt.org/

License: MIT License

Clojure 100.00%

docopt.clj's People

Contributors

felipecortez avatar signalpillar avatar thiagokokada avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docopt.clj's Issues

Manual help handling

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?

Does not seem to support string options with spaces or quotes for strings.

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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.