diff --git a/CHANGES.md b/CHANGES.md index 26290f6..605df64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +### 3.3.0 +* Rename the CLI tool to `mustache-ocaml`. It's now part of the new opam + package `mustache-cli` (@psafont, #71) + ### 3.2.0 * Remove the AST without locations: now all functions build an AST with locations; diff --git a/dune-project b/dune-project index 8ca9354..5d71a33 100644 --- a/dune-project +++ b/dune-project @@ -34,7 +34,7 @@ Read and write mustache templates, and render them. (name mustache-cli) (synopsis "CLI for Mustache logic-less templates") (description " -Command line utility `mustache` for driving logic-less templates. +Command line utility `mustache-ocaml` for driving logic-less templates. Read and write mustache templates, and render them by providing a json object. ") (depends diff --git a/mustache-cli.opam b/mustache-cli.opam index 7d0e2da..5557de4 100644 --- a/mustache-cli.opam +++ b/mustache-cli.opam @@ -3,7 +3,7 @@ opam-version: "2.0" synopsis: "CLI for Mustache logic-less templates" description: """ -Command line utility `mustache` for driving logic-less templates. +Command line utility `mustache-ocaml` for driving logic-less templates. Read and write mustache templates, and render them by providing a json object. """ maintainer: ["Rudi Grinberg "] diff --git a/mustache-cli/dune b/mustache-cli/dune index 9a135ad..c7cfcfa 100644 --- a/mustache-cli/dune +++ b/mustache-cli/dune @@ -1,13 +1,14 @@ (executable (name mustache_cli) - (public_name mustache) + (public_name mustache-ocaml) (package mustache-cli) (libraries mustache jsonm cmdliner)) (rule - (with-stdout-to - mustache.1 - (run mustache --help=groff))) + (deps (:bin mustache_cli.exe)) + (action + (with-stdout-to mustache.1 + (run %{bin} --help=groff)))) (install (section man) diff --git a/mustache-cli/test/dune b/mustache-cli/test/dune index cda3e93..ccc628a 100644 --- a/mustache-cli/test/dune +++ b/mustache-cli/test/dune @@ -1,2 +1,2 @@ (cram - (deps %{bin:mustache})) + (deps %{bin:mustache-ocaml})) diff --git a/mustache-cli/test/errors/dune b/mustache-cli/test/errors/dune index cda3e93..ccc628a 100644 --- a/mustache-cli/test/errors/dune +++ b/mustache-cli/test/errors/dune @@ -1,2 +1,2 @@ (cram - (deps %{bin:mustache})) + (deps %{bin:mustache-ocaml})) diff --git a/mustache-cli/test/errors/json-errors.t b/mustache-cli/test/errors/json-errors.t index 1914c7a..3c1c959 100644 --- a/mustache-cli/test/errors/json-errors.t +++ b/mustache-cli/test/errors/json-errors.t @@ -3,12 +3,12 @@ $ echo '{{foo}}' > foo.mustache Empty json file: - $ mustache empty.json foo.mustache + $ mustache-ocaml empty.json foo.mustache File "empty.json", line 1, character 0: expected JSON text (JSON value) [4] Invalid json file: - $ mustache invalid.json foo.mustache + $ mustache-ocaml invalid.json foo.mustache File "invalid.json", line 1, characters 15-29: expected value separator or object end (',' or '}') [4] diff --git a/mustache-cli/test/errors/parsing-errors.t b/mustache-cli/test/errors/parsing-errors.t index 8891cb6..9063a2d 100644 --- a/mustache-cli/test/errors/parsing-errors.t +++ b/mustache-cli/test/errors/parsing-errors.t @@ -3,62 +3,62 @@ Delimiter problems: $ PROBLEM=no-closing-mustache.mustache $ echo "{{foo" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "no-closing-mustache.mustache", line 2, character 0: '}}' expected. [3] $ PROBLEM=one-closing-mustache.mustache $ echo "{{foo}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "one-closing-mustache.mustache", line 1, character 5: '}}' expected. [3] $ PROBLEM=eof-before-variable.mustache $ echo "{{" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-variable.mustache", line 2, character 0: ident expected. [3] $ PROBLEM=eof-before-section.mustache $ echo "{{#" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-section.mustache", line 2, character 0: ident expected. [3] $ PROBLEM=eof-before-section-end.mustache $ echo "{{#foo}} {{.}} {{/" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-section-end.mustache", line 2, character 0: '}}' expected. [3] $ PROBLEM=eof-before-inverted-section.mustache $ echo "{{^" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-inverted-section.mustache", line 2, character 0: ident expected. [3] $ PROBLEM=eof-before-unescape.mustache $ echo "{{{" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-unescape.mustache", line 2, character 0: ident expected. [3] $ PROBLEM=eof-before-unescape.mustache $ echo "{{&" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-unescape.mustache", line 2, character 0: ident expected. [3] $ PROBLEM=eof-before-partial.mustache $ echo "{{>" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-before-partial.mustache", line 2, character 0: '}}' expected. [3] $ PROBLEM=eof-in-comment.mustache $ echo "{{! non-terminated comment" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "eof-in-comment.mustache", line 2, character 0: non-terminated comment. [3] @@ -67,13 +67,13 @@ Mismatches between opening and closing mustaches: $ PROBLEM=two-three.mustache $ echo "{{ foo }}}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "two-three.mustache", line 1, characters 7-10: '}}' expected. [3] $ PROBLEM=three-two.mustache $ echo "{{{ foo }}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "three-two.mustache", line 1, characters 8-10: '}}}' expected. [3] @@ -82,34 +82,34 @@ Mismatch between section-start and section-end: $ PROBLEM=foo-bar.mustache $ echo "{{#foo}} {{.}} {{/bar}}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "foo-bar.mustache", line 1, characters 0-23: Open/close tag mismatch: {{# foo }} is closed by {{/ bar }}. [3] $ PROBLEM=foo-not-closed.mustache $ echo "{{#foo}} {{.}} {{foo}}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "foo-not-closed.mustache", line 2, character 0: syntax error. [3] $ PROBLEM=wrong-nesting.mustache $ echo "{{#bar}} {{#foo}} {{.}} {{/bar}} {{/foo}}" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "wrong-nesting.mustache", line 1, characters 9-32: Open/close tag mismatch: {{# foo }} is closed by {{/ bar }}. [3] $ PROBLEM=wrong-nesting-variable.mustache $ echo '{{#bar}} {{$foo}} {{.}} {{/bar}} {{/foo}}' > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "wrong-nesting-variable.mustache", line 1, characters 9-32: Open/close tag mismatch: {{$ foo }} is closed by {{/ bar }}. [3] $ PROBLEM=wrong-nesting-partial.mustache $ echo "{{#foo}} {{ $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "wrong-nesting-partial.mustache", line 1, characters 9-30: Open/close tag mismatch: {{< foo-bar }} is closed by {{/ foo }}. [3] @@ -120,6 +120,6 @@ Weird cases that may confuse our lexer or parser: $ PROBLEM=weird-tag-name.mustache $ echo "{{.weird}} foo bar" > $PROBLEM - $ mustache foo.json $PROBLEM + $ mustache-ocaml foo.json $PROBLEM File "weird-tag-name.mustache", line 1, character 3: '}}' expected. [3] diff --git a/mustache-cli/test/errors/render-errors.t/run.t b/mustache-cli/test/errors/render-errors.t/run.t index 6e2c222..3ea17f5 100644 --- a/mustache-cli/test/errors/render-errors.t/run.t +++ b/mustache-cli/test/errors/render-errors.t/run.t @@ -1,5 +1,5 @@ reference.json and reference.mustache work well together, there is no error. - $ mustache reference.json reference.mustache + $ mustache-ocaml reference.json reference.mustache Title: Some Title List: @@ -26,58 +26,58 @@ one possible source of error, or both, or none. Invalid variable name: - $ mustache reference.json missing-variable.mustache + $ mustache-ocaml reference.json missing-variable.mustache File "missing-variable.mustache", line 14, characters 40-46: the variable 'na' is missing. [2] - $ mustache missing-variable.json reference.mustache + $ mustache-ocaml missing-variable.json reference.mustache File "reference.mustache", line 5, characters 4-12: the variable 'data' is missing. [2] Invalid section name: - $ mustache reference.json missing-section.mustache + $ mustache-ocaml reference.json missing-section.mustache File "missing-section.mustache", line 14, characters 0-55: the section 'na' is missing. [2] - $ mustache missing-section.json reference.mustache + $ mustache-ocaml missing-section.json reference.mustache File "reference.mustache", lines 9-12, characters 0-10: the section 'group' is missing. [2] Error in a dotted path foo.bar (one case for the first component, the other in the second). - $ mustache reference.json invalid-dotted-name-1.mustache + $ mustache-ocaml reference.json invalid-dotted-name-1.mustache File "invalid-dotted-name-1.mustache", line 10, characters 2-15: the variable 'gro' is missing. [2] - $ mustache invalid-dotted-name-1.json reference.mustache + $ mustache-ocaml invalid-dotted-name-1.json reference.mustache File "reference.mustache", lines 9-12, characters 0-10: the section 'group' is missing. [2] - $ mustache reference.json invalid-dotted-name-2.mustache + $ mustache-ocaml reference.json invalid-dotted-name-2.mustache File "invalid-dotted-name-2.mustache", line 10, characters 2-15: the variable 'group.fir' is missing. [2] - $ mustache invalid-dotted-name-2.json reference.mustache + $ mustache-ocaml invalid-dotted-name-2.json reference.mustache File "reference.mustache", line 10, characters 2-17: the variable 'group.first' is missing. [2] Non-scalar used as a scalar: - $ mustache reference.json non-scalar.mustache + $ mustache-ocaml reference.json non-scalar.mustache File "non-scalar.mustache", line 4, characters 0-8: the value of 'list' is not a valid scalar. [2] - $ mustache non-scalar.json reference.mustache + $ mustache-ocaml non-scalar.json reference.mustache File "reference.mustache", line 1, characters 7-16: the value of 'title' is not a valid scalar. [2] @@ -87,7 +87,7 @@ Missing partial (currently the CLI does not support any partial anyway): (this one does not) are all before in the alphabetic order, resulting in better `ls` output). - $ mustache reference.json z-missing-partial.mustache + $ mustache-ocaml reference.json z-missing-partial.mustache File "z-missing-partial.mustache", line 11, characters 2-13: the partial 'second' is missing. [2] diff --git a/mustache-cli/test/errors/sys-errors.t b/mustache-cli/test/errors/sys-errors.t index 6d89745..88eac93 100644 --- a/mustache-cli/test/errors/sys-errors.t +++ b/mustache-cli/test/errors/sys-errors.t @@ -2,14 +2,14 @@ $ echo "" > foo.mustache Nonexistent json file: - $ mustache nonexistent.json foo.mustache + $ mustache-ocaml nonexistent.json foo.mustache mustache: DATA.json argument: no 'nonexistent.json' file or directory Usage: mustache [-I DIR] [--no-working-dir] [OPTION]… DATA.json TEMPLATE.mustache Try 'mustache --help' for more information. [124] Nonexistent template file: - $ mustache foo.json nonexistent.mustache + $ mustache-ocaml foo.json nonexistent.mustache mustache: TEMPLATE.mustache argument: no 'nonexistent.mustache' file or directory Usage: mustache [-I DIR] [--no-working-dir] [OPTION]… DATA.json TEMPLATE.mustache diff --git a/mustache-cli/test/inheritance.t/run.t b/mustache-cli/test/inheritance.t/run.t index 90f570a..0b38c10 100644 --- a/mustache-cli/test/inheritance.t/run.t +++ b/mustache-cli/test/inheritance.t/run.t @@ -33,7 +33,7 @@ specification: https://github.com/mustache/spec/pull/75 {{$title}}Default title{{/title}} - $ mustache data.json mypage.mustache + $ mustache-ocaml data.json mypage.mustache My page title @@ -60,7 +60,7 @@ specification: https://github.com/mustache/spec/pull/75 {{/indented-block}} {{/test-indentation}} - $ mustache data.json test-indent-more.mustache + $ mustache-ocaml data.json test-indent-more.mustache

The test below should be indented in the same way as this line. This text is not indented in the source, @@ -75,7 +75,7 @@ specification: https://github.com/mustache/spec/pull/75 {{/indented-block}} {{/test-indentation}} - $ mustache data.json test-indent-less.mustache + $ mustache-ocaml data.json test-indent-less.mustache

The test below should be indented in the same way as this line. This text is very indented in the source, @@ -100,7 +100,7 @@ mandates that text be accepted and ignored, but we error on other tags. {{/content}} {{/base}} - $ mustache data.json invalid-partial-usage.mustache + $ mustache-ocaml data.json invalid-partial-usage.mustache File "invalid-partial-usage.mustache", lines 7-9, characters 2-14: Inside the partial block {{< base }}...{{/ base }}, we expect parameter blocks {{$foo}...{{/foo}} but no other sorts of tags. diff --git a/mustache-cli/test/manpage-examples.t/run.t b/mustache-cli/test/manpage-examples.t/run.t index a03891b..0e33331 100644 --- a/mustache-cli/test/manpage-examples.t/run.t +++ b/mustache-cli/test/manpage-examples.t/run.t @@ -11,7 +11,7 @@ Simple usage: - {{name}} {{/qualities}} - $ mustache data.json hello.mustache + $ mustache-ocaml data.json hello.mustache Hello OCaml! Mustache is: - simple @@ -27,7 +27,7 @@ Using a partial to include a subpage: - $ mustache data.json page.mustache + $ mustache-ocaml data.json page.mustache Hello OCaml! @@ -65,7 +65,7 @@ Using a partial with parameters to include a layout around a page: - $ mustache new-post.json post.mustache + $ mustache-ocaml new-post.json post.mustache Post: New Post diff --git a/mustache-cli/test/partials.t/run.t b/mustache-cli/test/partials.t/run.t index 6e68963..2db7dbc 100644 --- a/mustache-cli/test/partials.t/run.t +++ b/mustache-cli/test/partials.t/run.t @@ -1,5 +1,5 @@ Simple test: - $ mustache data.json foo.mustache + $ mustache-ocaml data.json foo.mustache Inside the include is "Foo Bar !" Include in child or parent directory: @@ -7,31 +7,31 @@ Include in child or parent directory: $ echo "Test from {{src}}" > subdir/test.mustache $ echo "{{> subdir/test }}" > from_parent.mustache $ echo '{ "src": "parent" }' > from_parent.json - $ mustache from_parent.json from_parent.mustache + $ mustache-ocaml from_parent.json from_parent.mustache Test from parent $ mkdir subdir/child $ echo "{{> ../test }}" > subdir/child/from_child.mustache $ echo '{ "src": "child" }' > subdir/child/from_child.json - $ (cd subdir/child; mustache from_child.json from_child.mustache) + $ (cd subdir/child; mustache-ocaml from_child.json from_child.mustache) Test from child When working with templates from outside the current directory, we need to set the search path to locate their included partials. This fails: - $ (cd subdir; mustache ../data.json ../foo.mustache) + $ (cd subdir; mustache-ocaml ../data.json ../foo.mustache) File "../foo.mustache", line 2, characters 23-31: the partial 'bar' is missing. [2] This works with the "-I .." option: - $ (cd subdir; mustache -I .. ../data.json ../foo.mustache) + $ (cd subdir; mustache-ocaml -I .. ../data.json ../foo.mustache) Inside the include is "Foo Bar !" Note that the include directory is *not* used to locate the template (or data) argument. This fails: - $ (cd subdir; mustache -I .. ../data.json foo.mustache) + $ (cd subdir; mustache-ocaml -I .. ../data.json foo.mustache) mustache: TEMPLATE.mustache argument: no 'foo.mustache' file or directory Usage: mustache [-I DIR] [--no-working-dir] [OPTION]… DATA.json TEMPLATE.mustache Try 'mustache --help' for more information. @@ -48,14 +48,14 @@ Search path precedence order. The include directory added first (left -I option) has precedence over the include directories added after: - $ (cd precedence; mustache -I first -I last data.json template.mustache) + $ (cd precedence; mustache-ocaml -I first -I last data.json template.mustache) First The working directory has precedence over the include directories: $ echo "Working" > precedence/include.mustache - $ (cd precedence; mustache -I first -I last data.json template.mustache) + $ (cd precedence; mustache-ocaml -I first -I last data.json template.mustache) Working ... unless --no-working-dir is used: - $ (cd precedence; mustache --no-working-dir -I first -I last data.json template.mustache) + $ (cd precedence; mustache-ocaml --no-working-dir -I first -I last data.json template.mustache) First