~technomancy/fnlfmt

ref: 419551b9c197181ab0bc310d9c87f69d05e04b6a fnlfmt/fnlfmt -rwxr-xr-x 488 bytes
419551b9jaawerth add support for stdin via `fnlfmt -` 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env fennel

(local fmt (require :fnlfmt))

(fn format [filename]
  (let [f (match filename
            :- io.stdin
            _ (assert (io.open filename :r) "File not found."))
        contents (f:read :*all)]
    (f:close)
    (print (fmt.fmt contents))))

(fn help []
  (print "Usage: fnlfmt FILENAME")
  (print "Prints the reformatted file to standard out."))

(if (or (not= (# arg) 1)
        (. {"--help" "-h" "-?" "help"} (. arg 1)))
    (help)
    (format (. arg 1)))