Input syntax
Lanat follows the syntax you would expect from a command-line interface, while also expanding it with some other features. A user that is familiar with other command-line programs will have no trouble using a program built with Lanat.
Let's take a deep dive into the syntax Lanat expects to parse.
Arguments
To refer to an argument, the syntax is: (Spaces shall not be present in the actual input)
The
namemust be any of the names defined in the argument.The
prefixmust be a single character matching the prefix of the argument.
Argument name lists
You can refer to multiple arguments at once by listing their names after a single prefix with the following syntax: (Spaces shall not be present in the actual input)
nXmust be any of the single character names defined in the argument.The
prefixmust be a single character matching any of the prefixes of any of the arguments specified in the list, or either-or/.
Argument values
After specifying an argument, you can provide a value to it by using the syntax:
When the
=is present, no spaces should be present between these tokens.valueis:[ tuple_start ] str1 [ str2... ] [ tuple_end ]tuple_[start|end]are the characters that define the start and end of a tuple. They are defined byTupleChar#current.strXis a string containing a value to be forwarded to the argument type.
Examples
Argument with value:
--name 12Expanded into:
Argument
name:Value:
12Prefix:
-
Argument name list:
-axvz 56Expanded into:
Arguments:
a,x,v,zValue (for z):
56Prefix:
-
Multiple arguments with multiple values:
/values 12 13 14 +t56Expanded into:
Argument
values:Values:
12,13,14Prefix:
/
Argument
t:Value:
56Prefix:
+
Value with tuple:
--users ["Alice" "Bob" "Charlie"] /t=[1]Expanded into:
Argument
users:Value:
{"Alice", "Bob", "Charlie"}Prefix:
-
Argument
t:Value:
1Prefix:
/
Forward value
In some cases it may be useful to allow the user to provide a generic value to the program without specifying an argument. This is called a forward value. The syntax is (including the space):
valueis a string containing anything. Lanat will not attempt to parse this.
Example
Simple program that would run another program (
grep) with some provided arguments forwarded to it:$ run-with --cmd "grep" -- -r "pattern" "file.txt"Expanded into:
Argument
cmd:Value:
grepPrefix:
-
Forward value:
-r "pattern" "file.txt"