updated the userguide to be nicer to read

This commit is contained in:
Izaya 2017-10-14 07:13:52 +11:00
parent 0eb85d39e5
commit aeffadfff8
1 changed files with 39 additions and 32 deletions

View File

@ -10,32 +10,36 @@ lush is the default shell of PsychOS. It allows executing functions in memory, p
The default prompt is `[<user>@<hostname> <current directory>]$`
Some example usage:
When you enter a command, lush will first check for functions with the given name.
If there's no function with the name, it will check for a files with the name in every directory in the PATH environment variable.
If lush can't find a file with that name, it will try to execute the line as Lua.
### running a function
```
[user@host /boot]$ =ps
function: 0x12ed5c0
```
This is checking if ps is indeed a function.
So, if one were to enter
```
[user@host /boot]$ ps
PID User Name
3 superu logflushd
4 superu ncd
5 superu tty[randomstringabcd]: 8f01b7c7,89734f0
6 superu kbd: 1f46ed58
7 superu kbd-clibboard: 1f46ed58
8 superu login manager: randomstringabcd
ps
```
This runs the ps function. You can also have arguments following the function name, separated by spaces.
lush checks for a function called ps, which in this case, it finds, and executes:
### running a program on disk
```
PID User Name
3 superu logflushd
4 superu ncd
5 superu tty[randomstringabcd]: 8f01b7c7,89734f0
6 superu kbd: 1f46ed58
7 superu kbd-clibboard: 1f46ed58
8 superu login manager: randomstringabcd
```
You have the following program stored as count.lua, in the current directory:
Okay, but what if there was no function?
You enter
```
count
```
and there's no function called count, but there is a file called count.lua in the current directory:
```
for i = 1, 5 do
@ -43,25 +47,28 @@ for i = 1, 5 do
end
```
To run it, all you need to do is:
```
[user@host /boot]$ count
```
lush will look for the function, not find it, see the file, and try to execute it:
You should get the expected output:
```
1
2
3
4
1
2
3
4
5
```
### running Lua code
Running Lua from lush is also simple, in that you just type it in.
And last, if you enter the Lua code:
```
[user@host /boot]$ for i = 1, 5 do print(i) end
for i = 1, 5 do print(i) end
```
You should get the same output as the last example.
lush will look for a function called for and not find it (magic is involved to make this sane), a file named for or for.lua, not find it, then fall back to executing Lua:
```
1
2
3
4
5
```