-
Notifications
You must be signed in to change notification settings - Fork 0
CLI
ebsl file=[file] key=[key] amt=[amount|max]
Argument | Purpose | Type |
---|---|---|
file | The file to read from | string |
key | The key in the file whose values to get | string |
amt | Gets the first amt values for a given key |
int or max
|
Once compiled, you can use the executable ebsl
to parse files. For example, in the following file, hello.ebsl
:
hello=world
bottle=green,blue,white
os=darwin
It could be parsed as follows:
./ebsl file=hello.ebsl key=bottle amt=2
This would get the first two values of bottle
(green and blue)
This can be parsed through on the user-end using a stream editor like sed or awk.
The amt
arg gets the first amt
values for a given key. For example, in house.ebsl
:
color=brown
floor=hardwood,brown
Here, running
./ebsl file=house.ebsl key=floor amt=2
would return
hardwood brown
If amt
was changed to 1, it would return the first value, hardwood
.
Tip
Don't use greater values
If amt
is set to more than the amount of values (e.g. 3), the result will vary per system.
On certain systems, it would return
hardwood brown brown
On other systems, specifically Darwin-based systems, it might return
hardwood brown
(Notice the two trailing spaces)
Instead, use max
.
Using the amt=max
argument will retrieve the maximum amount of values for a key. For example, consider apartment.ebsl
:
nature=true
garden=true
inside=wifi,landline,television
Running
./ebsl file=apartment.ebsl key=inside amt=max
Would return all of the values for inside
, i.e.
wifi landline television
The output delimiter sets the way the values are separated when output to the console. It can be set by setting the environment variable EBSL_OUT_DELIM
. However, it must be able to be used by child processes, so the export
command should be used.
In the shell, run:
export EBSL_OUT_DELIM=":"
Where :
can be left or replaced with your desired delimiter.
Consider the file computer.ebsl
:
computer=hp,arch
wallpaper=airport,moving,grey
Running:
./ebsl file=computer.ebsl key=wallpaper amt=3
with the :
delimiter would output:
airport:moving:grey:
Code | Case |
---|---|
0 | Success |
1 | Incorrect command usage |
2 | File could not be opened or key could not be found |
4 |
stoi invalid argument (amt not integer) |
If something is wrong here, please make an issue.