https://github.com/zaphar/clojure-flags
CommandLine flag parsing library
https://github.com/zaphar/clojure-flags
Last synced: 9 months ago
JSON representation
CommandLine flag parsing library
- Host: GitHub
- URL: https://github.com/zaphar/clojure-flags
- Owner: zaphar
- License: artistic-2.0
- Created: 2010-07-13T03:35:52.000Z (about 16 years ago)
- Default Branch: master
- Last Pushed: 2010-07-25T22:10:06.000Z (almost 16 years ago)
- Last Synced: 2025-07-07T12:07:21.455Z (about 1 year ago)
- Language: Clojure
- Homepage:
- Size: 105 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
Clojure Flags
=============
Usage:
------
A commandline flag parsing library.
clojure-flags allows you to:
1. Specify the flags anywhere in your code.
2. Self Document flags
3. Type checking flags.
(require '[com.marzhillstudios.flags :as flags])
(defflag :string "string-flag"
"Documentation about the flag")
(defflag :bool "bool-flag"
"Documentation about the bool flag")
(defn -main [& args]
(flags/parse args) ; parse the command line arguments
(do
(let [string-flag-val (get-flag "string-flag")] ; retrieve the flag value
(some-fun (flags/unparsed-args)))))
You can define your own flag type handlers using the defflag-type function:
(defflag-type :type-specifier (fn [matched] (last %1)))
The function will get one argument which will be the vector returned
from parsing the flag the last item in the vector will be the value, the
third item will be the flags name. You will mostly only care about the third.
Leiningen
---------
clojure-flags in hosted on clojars. To use it in your project just: include
this [clojure-flags "0.01.0"] in your projects :dependencies list.