Skip to content

Commit

Permalink
Add new functions
Browse files Browse the repository at this point in the history
  • Loading branch information
laniakea64 committed Mar 4, 2024
1 parent 687c162 commit ace92c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion syntax/just.vim
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ syn cluster justOtherCurlyBraces contains=justCurlyBraces,justBadCurlyBraces
syn match justFunctionCall "\v\w+%(\s|\\\n)*\(@=" transparent contains=justBuiltInFunction

syn keyword justBuiltInFunction
\ absolute_path arch cache_directory capitalize clean config_directory config_local_directory data_directory data_local_directory env env_var env_var_or_default executable_directory extension file_name file_stem home_directory invocation_directory invocation_directory_native join just_executable justfile justfile_directory just_pid kebabcase lowercamelcase lowercase num_cpus os os_family parent_directory path_exists quote replace replace_regex semver_matches sha256 sha256_file shoutykebabcase shoutysnakecase snakecase titlecase trim trim_end trim_end_match trim_end_matches trim_start trim_start_match trim_start_matches uppercamelcase uppercase uuid without_extension
\ absolute_path arch blake3 blake3_file cache_directory canonicalize capitalize clean config_directory config_local_directory data_directory data_local_directory env env_var env_var_or_default executable_directory extension file_name file_stem home_directory invocation_directory invocation_directory_native join just_executable justfile justfile_directory just_pid kebabcase lowercamelcase lowercase num_cpus os os_family parent_directory path_exists quote replace replace_regex semver_matches sha256 sha256_file shoutykebabcase shoutysnakecase snakecase titlecase trim trim_end trim_end_match trim_end_matches trim_start trim_start_match trim_start_matches uppercamelcase uppercase uuid without_extension
\ contained

syn match justUserDefinedError "\verror%(%(\s|\\\n)*\()@="
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/recipes-with-extras.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<span class="Number"> uname -a</span>

p1 <span class="Operator">:=</span> <span class="String">'test'</span>
p2 <span class="Operator">:=</span> <span class="String">'OtherTest'</span>
p2 <span class="Operator">:=</span> <span class="Function">canonicalize</span>(<span class="String">'..'</span>)
param <span class="Operator">:=</span> <span class="Function">semver_matches</span>(<span class="String">'0.1.1'</span>, <span class="String">'&gt;=0.1.0'</span>)

<span class="Special">@</span><span class="Function">foo1</span> <span class="Identifier">param1</span> <span class="Identifier">param2</span><span class="Operator">=</span><span class="String">"default test"</span> <span class="Statement">+</span><span class="Identifier">varparam</span><span class="Operator">=</span><span class="String">'default'</span><span class="Operator">:</span> <span class="Function">dependency1</span> <span class="Delimiter">(</span><span class="Function">dependency2</span> p1 p2<span class="Delimiter">)</span> <span class="Delimiter">(</span><span class="Function">dependency3</span> param<span class="Delimiter">)</span>
Expand All @@ -21,7 +21,7 @@
<span class="Number"> /bin/echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Identifier">firstparam</span><span class="Normal">)</span><span class="Delimiter">}}</span>
<span class="Number"> /bin/echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Identifier">secondparam</span><span class="Normal">)</span><span class="Delimiter">}}</span>

<span class="Function">dependency3</span> <span class="Identifier">theparam</span><span class="Operator">=</span><span class="Delimiter">(</span><span class="String">'a'</span> <span class="Operator">+</span> (<span class="Conditional">if</span> <span class="Function">env_var_or_default</span>(<span class="String">'FOO'</span>, <span class="Function">sha256</span>(<span class="Function">justfile</span>())) <span class="Operator">==</span> <span class="String">'1'</span> { <span class="String">' With Foo'</span>} <span class="Conditional">else</span> { <span class="String">' none '</span> <span class="Operator">+</span> p1 <span class="Operator">/</span> p2 }) <span class="Operator">/</span> <span class="String">'b'</span><span class="Delimiter">)</span><span class="Operator">:</span>
<span class="Function">dependency3</span> <span class="Identifier">theparam</span><span class="Operator">=</span><span class="Delimiter">(</span><span class="String">'a'</span> <span class="Operator">+</span> (<span class="Conditional">if</span> <span class="Function">env_var_or_default</span>(<span class="String">'FOO'</span>, <span class="Function">blake3_file</span>(<span class="Function">justfile</span>())) <span class="Operator">==</span> <span class="String">'1'</span> { <span class="String">' With Foo'</span>} <span class="Conditional">else</span> { <span class="String">' none '</span> <span class="Operator">+</span> p1 <span class="Operator">/</span> p2 }) <span class="Operator">/</span> <span class="String">'b'</span><span class="Delimiter">)</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Identifier">theparam</span><span class="Normal">)</span><span class="Delimiter">}}</span>

<span class="Function">test4</span><span class="Operator">:</span> <span class="Delimiter">(</span><span class="Function">dependency2</span> <span class="String">"123"</span>
Expand Down Expand Up @@ -90,8 +90,8 @@
<span class="Function">interp_with_func_with_arg</span> <span class="Identifier">foo</span><span class="Operator">:</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Normal">)</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">join</span><span class="Normal">(</span><span class="String">'test'</span><span class="Normal">,</span><span class="Identifier">foo</span><span class="Normal">, </span><span class="Special">`echo Bar`</span><span class="Normal">, </span><span class="Identifier">somevar</span><span class="Normal">, </span><span class="String">"2"</span><span class="Normal">)</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Function">sha256</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">"-"</span><span class="Normal">))</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="String">'x'</span><span class="Normal"> </span><span class="Operator">+</span><span class="Normal"> </span><span class="Function">sha256</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">"-"</span><span class="Operator">+</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">'-'</span><span class="Operator">+</span><span class="Identifier">foo</span><span class="Normal">) </span><span class="Operator">+</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Operator">+</span><span class="Normal"> </span><span class="String">'y'</span><span class="Normal">)</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Function">blake3</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">"-"</span><span class="Normal">))</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="String">'x'</span><span class="Normal"> </span><span class="Operator">+</span><span class="Normal"> </span><span class="Function">blake3</span><span class="Normal">(</span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">"-"</span><span class="Operator">+</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Operator">+</span><span class="String">'-'</span><span class="Operator">+</span><span class="Identifier">foo</span><span class="Normal">) </span><span class="Operator">+</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Operator">+</span><span class="Normal"> </span><span class="String">'y'</span><span class="Normal">)</span><span class="Delimiter">}}</span>
<span class="Number"> echo </span><span class="Delimiter">{{</span><span class="Function">quote</span><span class="Normal">(</span><span class="Conditional">if</span><span class="Normal"> </span><span class="Identifier">foo</span><span class="Normal"> </span><span class="Operator">==</span><span class="Normal"> </span><span class="String">'123'</span><span class="Normal"> { </span><span class="String">'321'</span><span class="Normal"> } </span><span class="Conditional">else</span><span class="Normal"> { </span><span class="String">'foo bar'</span><span class="Normal"> } )</span><span class="Delimiter">}}</span>

<span class="Function">interp_with_conditional</span> <span class="Identifier">foo</span><span class="Operator">:</span>
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/recipes-with-extras.just
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ foo: # comment
uname -a

p1 := 'test'
p2 := 'OtherTest'
p2 := canonicalize('..')
param := semver_matches('0.1.1', '>=0.1.0')

@foo1 param1 param2="default test" +varparam='default': dependency1 (dependency2 p1 p2) (dependency3 param)
Expand All @@ -21,7 +21,7 @@ dependency2 firstparam=("abc\t" / 'def\t\"') secondparam=("""
/bin/echo {{quote(firstparam)}}
/bin/echo {{quote(secondparam)}}

dependency3 theparam=('a' + (if env_var_or_default('FOO', sha256(justfile())) == '1' { ' With Foo'} else { ' none ' + p1 / p2 }) / 'b'):
dependency3 theparam=('a' + (if env_var_or_default('FOO', blake3_file(justfile())) == '1' { ' With Foo'} else { ' none ' + p1 / p2 }) / 'b'):
echo {{quote(theparam)}}

test4: (dependency2 "123"
Expand Down Expand Up @@ -90,8 +90,8 @@ somevar := "1"
interp_with_func_with_arg foo:
echo {{quote(foo)}}
echo {{join('test',foo, `echo Bar`, somevar, "2")}}
echo {{quote(sha256(foo+"-"))}}
echo {{quote('x' + sha256(foo+"-"+ foo+'-'+foo) + foo+ 'y')}}
echo {{quote(blake3(foo+"-"))}}
echo {{quote('x' + blake3(foo+"-"+ foo+'-'+foo) + foo+ 'y')}}
echo {{quote(if foo == '123' { '321' } else { 'foo bar' } )}}

interp_with_conditional foo:
Expand Down

0 comments on commit ace92c3

Please sign in to comment.