Skip to content

Commit

Permalink
Make shflags completely optional
Browse files Browse the repository at this point in the history
Fixes #16.
  • Loading branch information
hugoduncan committed Jul 9, 2011
1 parent 13554de commit 3710a9a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/pallet/stevedore/bash.clj
Expand Up @@ -76,8 +76,9 @@
(str (when (string? doc?)
(str (shflags-doc-string doc?)))
(when (seq flags)
(str (apply str (map (partial apply shflags-declare) flags))))
(shflags-setup)
(str
(apply str (map (partial apply shflags-declare) flags))
(shflags-setup)))
(when (seq args)
(str
(string/join
Expand Down
4 changes: 2 additions & 2 deletions test/pallet/script/lib_test.clj
Expand Up @@ -38,7 +38,7 @@
(~declare-arguments
[[:string asdf a "asdf" "e"]]))))
"Only flags")
(is (= "FLAGS \"$@\" || exit 1\neval set -- \"${FLAGS_ARGV}\"\na=$1\nb=$2\nc=$3\n"
(is (= "a=$1\nb=$2\nc=$3\n"
(with-script-context [:default]
(stevedore/script
(~declare-arguments
Expand All @@ -51,7 +51,7 @@
[a b c
[:string asdf a "asdf" "e"]]))))
"Without docstring")
(is (= "FLAGS \"$@\" || exit 1\neval set -- \"${FLAGS_ARGV}\"\n"
(is (= ""
(with-script-context [:default]
(stevedore/script
(~declare-arguments
Expand Down
4 changes: 2 additions & 2 deletions test/pallet/stevedore/bash_test.clj
Expand Up @@ -101,7 +101,7 @@
(foo a) (bar b)))))
"anonymous")

(is (= "foo() {\nFLAGS \"$@\" || exit 1\neval set -- \"${FLAGS_ARGV}\"\nx=$1\ny=$2\nfoo a\nbar b\n}"
(is (= "foo() {\nx=$1\ny=$2\nfoo a\nbar b\n}"
(strip-ws (script (defn foo [x y]
(foo a) (bar b)))))
"without flags")
Expand Down Expand Up @@ -280,7 +280,7 @@
(let [stuff (quote (do
(local x 3)
(local y 4)))]
(is (= "foo() {\nFLAGS \"$@\" || exit 1\neval set -- \"${FLAGS_ARGV}\"\nx=$1\nlocal x=3\nlocal y=4\n}"
(is (= "foo() {\nx=$1\nlocal x=3\nlocal y=4\n}"
(strip-ws (script (defn foo [x] ~stuff))))))))

(deftest defvar-test
Expand Down

0 comments on commit 3710a9a

Please sign in to comment.