8000 GitHub - daveyarwood/str-to-argv: parse command-line arguments from a single string in Clojure
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

daveyarwood/str-to-argv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

str-to-argv

Clojars Project

What? Why?

This library serves the very niche purpose of parsing command-line arguments from a single string in Clojure. Usually, your shell takes care of splitting command-line arguments, so this is something you would never need to do manually. Once in a blue moon, though, you may need to do this. So, here's some code that does it.

The implementation is copy-pasted from Michał Marczyk's answer to the StackOverflow question linked above. After lots of googling, it was the best solution I could find. I was hesitant to include it in the project where I needed it, so I made a reusable library out of it.

Note: I'm totally prepared to scrap this and replace it with something less convoluted (Michał's word, not mine!), if something comes up.

This solution is also from 2010, at which point there apparently (from reading the comments) wasn't a proper parser-generator library available. Perhaps we could now build a simpler solution using Instaparse.

Usage

(require '[str-to-argv :refer (split-args)])

(split-args "foo --bar 'baz quux'")
;=> ("foo" "--bar" "baz quux")

About

parse command-line arguments from a single string in Clojure

Resources

Stars

Watchers

Forks

Packages

No packages published
0