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
name
must be any of the names defined in the argument.The
prefix
must 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)
nX
must be any of the single character names defined in the argument.The
prefix
must 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.value
is:[ 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
.strX
is a string containing a value to be forwarded to the argument type.
Examples
Argument with value:
--name 12Expanded into:
Argument
name
:Value:
12
Prefix:
-
Argument name list:
-axvz 56Expanded into:
Arguments:
a
,x
,v
,z
Value (for z):
56
Prefix:
-
Multiple arguments with multiple values:
/values 12 13 14 +t56Expanded into:
Argument
values
:Values:
12
,13
,14
Prefix:
/
Argument
t
:Value:
56
Prefix:
+
Value with tuple:
--users ["Alice" "Bob" "Charlie"] /t=[1]Expanded into:
Argument
users
:Value:
{"Alice", "Bob", "Charlie"}
Prefix:
-
Argument
t
:Value:
1
Prefix:
/
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):
value
is 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:
grep
Prefix:
-
Forward value:
-r "pattern" "file.txt"