Skip to content

Commit

Permalink
cli: change binary name to mustache-ocaml
Browse files Browse the repository at this point in the history
resolves rgrinberg#61

Signed-off-by: Pau Ruiz Safont <pau.ruizsafont@cloud.com>
  • Loading branch information
psafont committed Nov 24, 2023
1 parent a278ab1 commit 18a4f82
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mustache-cli.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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 <me@rgrinerg.com>"]
Expand Down
9 changes: 5 additions & 4 deletions mustache-cli/dune
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mustache-cli/test/dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(cram
(deps %{bin:mustache}))
(deps %{bin:mustache-ocaml}))
2 changes: 1 addition & 1 deletion mustache-cli/test/errors/dune
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(cram
(deps %{bin:mustache}))
(deps %{bin:mustache-ocaml}))
4 changes: 2 additions & 2 deletions mustache-cli/test/errors/json-errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -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]
36 changes: 18 additions & 18 deletions mustache-cli/test/errors/parsing-errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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]

Expand All @@ -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}} {{<foo-bar}} {{/foo}} {{/foo-bar}}" > $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]
Expand All @@ -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]
24 changes: 12 additions & 12 deletions mustache-cli/test/errors/render-errors.t/run.t
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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]
Expand All @@ -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]
4 changes: 2 additions & 2 deletions mustache-cli/test/errors/sys-errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions mustache-cli/test/inheritance.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ specification: https://github.com/mustache/spec/pull/75
<title>{{$title}}Default title{{/title}}</title>
</head>
$ mustache data.json mypage.mustache
$ mustache-ocaml data.json mypage.mustache
<html>
<head>
<title>My page title</title>
Expand All @@ -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
<p>
The test below should be indented in the same way as this line.
This text is not indented in the source,
Expand All @@ -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
<p>
The test below should be indented in the same way as this line.
This text is very indented in the source,
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions mustache-cli/test/manpage-examples.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Simple usage:
- {{name}}
{{/qualities}}
$ mustache data.json hello.mustache
$ mustache-ocaml data.json hello.mustache
Hello OCaml!
Mustache is:
- simple
Expand All @@ -27,7 +27,7 @@ Using a partial to include a subpage:
</body>
</html>
$ mustache data.json page.mustache
$ mustache-ocaml data.json page.mustache
<html>
<body>
Hello OCaml!
Expand Down Expand Up @@ -65,7 +65,7 @@ Using a partial with parameters to include a layout around a page:
</body>
</html>
$ mustache new-post.json post.mustache
$ mustache-ocaml new-post.json post.mustache
<html>
<head>
<title>Post: New Post</title>
Expand Down
Loading

0 comments on commit 18a4f82

Please sign in to comment.