diff options
| author | 2023-06-29 14:47:17 +0600 | |
|---|---|---|
| committer | 2023-06-29 14:47:17 +0600 | |
| commit | 3cb3c6b9e7bdb77c69e7ac2d0db047a6dd2aac21 (patch) | |
| tree | 8db1826efb04776b0159463862d0239801123b7d /bin | |
| parent | Merge pull request #128 from primo-ppcg/timeit-loop (diff) | |
fmt: Add configuration
Example config file .janet-config.jdn
["phony"]
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/janet-format | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/bin/janet-format b/bin/janet-format index bb23873..4d919fc 100644 --- a/bin/janet-format +++ b/bin/janet-format @@ -3,6 +3,8 @@ (import spork/fmt) (import spork/argparse) +(def- default-config ".janet-format.jdn") + (defn- main [&] @@ -27,11 +29,30 @@ "input" {:short "i" :kind :option - :help "Read from an input file"})) + :help "Read from an input file"} + + "config" + {:short "c" + :kind :option + :help "Which configuration file to read" + :default default-config} + + "no-config" + {:short "n" + :kind :flag + :help "Avoid loading any configuration"})) # Break on help text (unless ap (break)) + (unless (ap "no-config") + (def config (ap "config")) + (def [exists contents] (protect (slurp config))) + (if exists + (setdyn fmt/*user-indent-2-forms* (parse contents)) + (when (not= config default-config) + (eprintf "Configuration file '%s' does not exist" config)))) + (if (or (ap "files") (ap :default)) (each file (ap :default) (eprint "formatting " file "...") |
