Skip to content

Commit 8df6629

Browse files
committed
Add initial README file with project overview, features, and usage instructions
1 parent b087d3b commit 8df6629

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Here’s a draft for your project’s README file:
2+
3+
---
4+
5+
# GLOS (Go/Lua OS)
6+
7+
GLOS is a fun experiment in lightweight userland toy OS development that blends Go and Lua, providing a simple yet flexible platform for script execution and file manipulation. It features an in-memory filesystem, environment variables, and a Lua-based command API for seamless interaction.
8+
9+
## Features
10+
11+
- **Lua Execution**: Run Lua scripts interactively.
12+
- **In-Memory Filesystem**: Store and manage files without persistent disk usage.
13+
- **Environment Variables**: Set and retrieve key-value pairs within the session.
14+
- **Command REPL**: A simple shell interface for executing scripts and managing files.
15+
- **Sandboxed Execution**: Restricted Lua environment for safety.
16+
17+
## Getting Started
18+
19+
### Prerequisites
20+
21+
- Go 1.18+
22+
- [GopherLua](https://github.com/yuin/gopher-lua)
23+
24+
### Installation
25+
26+
Clone the repository and build the project:
27+
28+
```sh
29+
git clone https://github.com/yourusername/glos.git
30+
cd glos
31+
go mod tidy
32+
go build .
33+
```
34+
35+
Run the REPL:
36+
37+
```sh
38+
./glos
39+
```
40+
41+
## API Reference
42+
43+
### File Operations
44+
45+
| Lua Function | Description | Example |
46+
|-------------|-------------|---------|
47+
| `read_file(filename)` | Reads and returns the contents of a file. | `content = read_file("test.txt")` |
48+
| `write_file(filename, content)` | Writes content to a file. | `write_file("test.txt", "Hello, GLOS!")` |
49+
| `delete_file(filename)` | Deletes a file. | `delete_file("test.txt")` |
50+
| `list_files()` | Returns a table of all stored files. | `files = list_files()` |
51+
52+
### Environment Variables
53+
54+
| Lua Function | Description | Example |
55+
|-------------|-------------|---------|
56+
| `set_env(name, value)` | Sets an environment variable. | `set_env("username", "Alice")` |
57+
| `get_env(name)` | Retrieves an environment variable's value. | `print(get_env("username"))` |
58+
59+
### Utility Functions
60+
61+
| Lua Function | Description | Example |
62+
|-------------|-------------|---------|
63+
| `clear_screen()` | Clears the terminal screen. | `clear_screen()` |
64+
| `read_multiline_input()` | Reads multiple lines until `:exit`. | `content = read_multiline_input()` |
65+
66+
## Example Lua Scripts
67+
68+
Several example scripts demonstrate the API usage:
69+
70+
- `cat.lua`: Reads and prints file contents.
71+
- `ls.lua`: Lists all stored files.
72+
- `rm.lua`: Deletes a specified file.
73+
- `write.lua`: Interactive text input for file writing.
74+
- `clear.lua`: Clears the terminal.
75+
- `help.lua`: Displays basic REPL commands.
76+
77+
## Usage
78+
79+
Run scripts using the REPL:
80+
81+
```sh
82+
glos> run ls.lua
83+
Files in memory:
84+
- test.txt
85+
- script.lua
86+
87+
glos> run write.lua example.txt
88+
Enter content line by line. Type ':exit' to finish.
89+
Hello, world!
90+
:exit
91+
92+
glos> run cat.lua example.txt
93+
Hello, world!
94+
95+
glos> exit
96+
```
97+
98+
## Contribution
99+
100+
Feel free to fork and improve the project! Contributions, bug reports, and suggestions are welcome.

0 commit comments

Comments
 (0)