fazer-lang 2.1.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -220
- package/docs/README.md +26 -0
- package/docs/examples.md +60 -0
- package/docs/getting-started.md +46 -0
- package/docs/stdlib.md +139 -0
- package/docs/syntax.md +86 -0
- package/fazer.js +475 -86
- package/package.json +22 -12
- package/tools/announce.fz +48 -0
- package/apply_icon.js +0 -28
- package/apply_icon_robust.js +0 -51
- package/bin/fazer.exe +0 -0
- package/package.json.bak +0 -44
- package/standalone.bundled.js +0 -12910
- package/standalone.js +0 -186
- package/test.fz +0 -92
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Fazer Corp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,241 +1,49 @@
|
|
|
1
|
-
# Fazer
|
|
1
|
+
# Fazer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
> *Copyright © 2026 L'EMPRISE. All Rights Reserved.*
|
|
3
|
+
**Fazer** — Le langage de script nouvelle génération par **L'EMPRISE**.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
Conçu pour l'automatisation, la sécurité et le traitement de données, Fazer combine une syntaxe concise avec une bibliothèque standard "batteries included".
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
## Installation
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
**Fazer (fz)** is not just another scripting language. It is a precision tool engineered by **L'EMPRISE** for developers who demand **clarity**, **security**, and **efficiency**.
|
|
14
|
-
|
|
15
|
-
Unlike traditional languages that bury logic in verbose syntax, Fazer prioritizes the **Data Flow**. By utilizing the revolutionary Arrow Pipe Operator (`→>`), Fazer allows data to flow naturally from one operation to the next, mirroring the human thought process.
|
|
16
|
-
|
|
17
|
-
### Why Fazer?
|
|
18
|
-
|
|
19
|
-
* **Superior Readability**: Logic flows left-to-right. No more nesting hell `func(func(func(x)))`.
|
|
20
|
-
* **Security First**: AES-256-GCM encryption is a first-class citizen, not an afterthought.
|
|
21
|
-
* **Batteries Included**: HTTP Server, FileSystem, System Execution, and JSON parsing are built-in. No external dependencies required for standard tasks.
|
|
22
|
-
* **Universal Compatibility**: Runs on any Node.js environment or compiles to a standalone, dependency-free Binary (EXE/Linux).
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## 2. Installation
|
|
27
|
-
|
|
28
|
-
### Global Installation (Recommended)
|
|
29
|
-
To access the `fazer` command globally on your system:
|
|
9
|
+
Installez Fazer globalement via npm :
|
|
30
10
|
|
|
31
11
|
```bash
|
|
32
12
|
npm install -g fazer-lang
|
|
33
13
|
```
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
fazer --version
|
|
38
|
-
# Output: 2.1.0
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## 3. The Core Philosophy: The Pipe (`→>`)
|
|
44
|
-
|
|
45
|
-
In most languages, you write:
|
|
46
|
-
```javascript
|
|
47
|
-
// JavaScript / Python style
|
|
48
|
-
print(sha256(readFile("data.txt")));
|
|
49
|
-
```
|
|
50
|
-
This requires reading "inside-out".
|
|
51
|
-
|
|
52
|
-
**In Fazer, you write:**
|
|
53
|
-
```fazer
|
|
54
|
-
"data.txt" →> readText() →> sha256() →> print()
|
|
55
|
-
```
|
|
56
|
-
This is the **Pipeline Architecture**. The result of the left side is automatically injected as the *first argument* of the function on the right.
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## 4. Language Guide
|
|
61
|
-
|
|
62
|
-
### Variables & Constants
|
|
63
|
-
Fazer uses dynamic typing. Variables are declared implicitly.
|
|
64
|
-
|
|
65
|
-
```fazer
|
|
66
|
-
x = 10
|
|
67
|
-
name = "L'EMPRISE"
|
|
68
|
-
isActive = true
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Data Types
|
|
72
|
-
* **String**: `"Hello World"` (supports concatenation with `+`)
|
|
73
|
-
* **Number**: `42`, `3.14`
|
|
74
|
-
* **Boolean**: `true`, `false`
|
|
75
|
-
* **Object/Map**: `{"key": "value"}`
|
|
76
|
-
* **Null**: `null`
|
|
77
|
-
|
|
78
|
-
### Control Flow: The Power of `case`
|
|
79
|
-
Fazer replaces the archaic `if/else/switch` with a unified, powerful `case` structure.
|
|
80
|
-
|
|
81
|
-
```fazer
|
|
82
|
-
fn analyze(val) →
|
|
83
|
-
case val
|
|
84
|
-
0 → println("Zero detected") end
|
|
85
|
-
> 100 → println("High value detected") end
|
|
86
|
-
"admin" → println("Access Granted") end
|
|
87
|
-
else → println("Unknown value") end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Functions (`fn`)
|
|
93
|
-
Functions are first-class citizens.
|
|
94
|
-
|
|
95
|
-
```fazer
|
|
96
|
-
fn multiply(a, b) →
|
|
97
|
-
return(a * b)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# Using with pipe
|
|
101
|
-
5 →> multiply(10) →> println() # Output: 50
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## 5. Standard Library Reference (StdLib)
|
|
107
|
-
|
|
108
|
-
Fazer comes equipped with a professional-grade standard library.
|
|
109
|
-
|
|
110
|
-
### 5.1. Input / Output & UI (`IO`)
|
|
15
|
+
## Utilisation Rapide
|
|
111
16
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* **`style(text, color)`**: Applies ANSI colors to text.
|
|
116
|
-
* *Colors*: `"red"`, `"green"`, `"yellow"`, `"blue"`, `"magenta"`, `"cyan"`, `"white"`, `"gray"`.
|
|
117
|
-
* **`box(title, lines...)`**: Renders a professional ASCII interface box. Automatically handles alignment and ANSI codes.
|
|
118
|
-
|
|
119
|
-
```fazer
|
|
120
|
-
box("SYSTEM ALERT", "Access Restricted", style("L'EMPRISE Protocol", "red"))
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 5.2. Cryptography (`Crypto`)
|
|
124
|
-
**Security Level: Military Grade (AES-256-GCM).**
|
|
125
|
-
|
|
126
|
-
* **`sha256(data)`**: Returns the SHA-256 hash of the data (hex string).
|
|
127
|
-
* **`encText(plainText, password)`**: Encrypts text using AES-256-GCM. Returns a secure JSON string containing IV, AuthTag, and Ciphertext.
|
|
128
|
-
* **`decText(encryptedJson, password)`**: Decrypts the JSON string. Throws error if password is wrong or integrity is compromised.
|
|
129
|
-
|
|
130
|
-
```fazer
|
|
131
|
-
pass = "super_secret"
|
|
132
|
-
"My Secret Data" →> encText(pass) →> saveText("secret.enc")
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### 5.3. File System (`FS`)
|
|
136
|
-
Robust, synchronous file operations.
|
|
137
|
-
|
|
138
|
-
* **`readText(path)`**: Reads file as UTF-8 string.
|
|
139
|
-
* **`saveText(content, path)`**: Writes string to file (overwrites).
|
|
140
|
-
* **`readB64(path)`**: Reads file as Base64 string (useful for binaries).
|
|
141
|
-
* **`saveB64(content, path)`**: Writes Base64 string to file.
|
|
142
|
-
* **`exists(path)`**: Returns `true` if file/directory exists, `false` otherwise.
|
|
143
|
-
* **`ls(path)`**: Returns an array of file names in the directory.
|
|
144
|
-
* **`rm(path)`**: Recursively deletes a file or directory. **Handle with care.**
|
|
145
|
-
* **`mkdir(path)`**: Creates a directory (recursive).
|
|
146
|
-
|
|
147
|
-
### 5.4. Networking & Web (`Net`)
|
|
148
|
-
Create high-performance web servers instantly.
|
|
149
|
-
|
|
150
|
-
* **`server(port, handlerFunctionName)`**: Starts a blocking HTTP server.
|
|
151
|
-
|
|
152
|
-
**Example Web Server:**
|
|
153
|
-
```fazer
|
|
154
|
-
fn handler(req) →
|
|
155
|
-
# req has .method, .url, .headers
|
|
156
|
-
println("Hit: " + req.url)
|
|
157
|
-
|
|
158
|
-
return({
|
|
159
|
-
"status": 200,
|
|
160
|
-
"headers": { "Content-Type": "application/json" },
|
|
161
|
-
"body": json({ "message": "Welcome to Fazer API" })
|
|
162
|
-
})
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
server(3000, "handler")
|
|
17
|
+
Lancer le REPL (mode interactif) :
|
|
18
|
+
```bash
|
|
19
|
+
fazer
|
|
166
20
|
```
|
|
167
21
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* **`exec(command)`**: Executes a shell command and returns the output (stdout).
|
|
171
|
-
* **`json(obj)`**: Serializes an object/array to a JSON string.
|
|
172
|
-
* **`parseJson(jsonString)`**: Parses a JSON string into an object.
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
## 6. Advanced Usage: Building Standalone Executables
|
|
177
|
-
|
|
178
|
-
You can compile your Fazer scripts into standalone executables (`.exe` for Windows, binary for Linux) that do not require Node.js or Fazer to be installed on the target machine.
|
|
179
|
-
|
|
180
|
-
**Command:**
|
|
22
|
+
Exécuter un script :
|
|
181
23
|
```bash
|
|
182
|
-
|
|
183
|
-
pkg fazer.js --targets node18-win-x64,node18-linux-x64 --output my_app
|
|
24
|
+
fazer mon_script.fz
|
|
184
25
|
```
|
|
185
26
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## 8. Fazer vs The World: A Technical Comparison
|
|
191
|
-
|
|
192
|
-
Why choose Fazer when you have JavaScript, Python, or Go? Because Fazer is designed for a specific purpose: **High-level Orchestration with Low-level Power**.
|
|
193
|
-
|
|
194
|
-
### 8.1. Fazer vs JavaScript / Node.js
|
|
195
|
-
|
|
196
|
-
* **The Problem with JS**: "Callback Hell" and "Promise Chaining". JavaScript forces you to write code "inside-out" or manage endless `.then()` chains.
|
|
197
|
-
* *JS*: `process(parse(read(file)))`
|
|
198
|
-
* **The Fazer Solution**: Linear data flow. The pipe operator (`→>`) is not just sugar; it's the core of the language.
|
|
199
|
-
* *Fazer*: `file →> read() →> parse() →> process()`
|
|
200
|
-
* **Ecosystem**: To get encryption, HTTP server, and file system operations in Node.js, you often need to install external packages or write boilerplate code using `fs`, `http`, and `crypto` modules. Fazer includes these batteries **natively**. `encText` and `server` are there from line 1.
|
|
201
|
-
|
|
202
|
-
### 8.2. Fazer vs Python
|
|
203
|
-
|
|
204
|
-
* **Distribution**: Sharing a Python script is painful. The user needs Python installed, then `pip install -r requirements.txt`, and version conflicts are common.
|
|
205
|
-
* **Fazer's Edge**: Fazer compiles to a **single, standalone binary** (EXE for Windows, Bin for Linux). You give the file to the user, they double-click, and it runs. No installation, no dependencies, no friction.
|
|
206
|
-
* **Performance**: While Python interprets line-by-line, Fazer's lightweight runtime is optimized for rapid I/O and cryptographic operations, making it feel snappier for CLI tools.
|
|
207
|
-
|
|
208
|
-
### 8.3. Fazer vs Bash / Shell
|
|
209
|
-
|
|
210
|
-
* **Cross-Platform Nightmare**: A Bash script written for Linux often fails on Windows (PowerShell/CMD) or macOS due to syntax differences (`ls` vs `dir`, `/` vs `\`).
|
|
211
|
-
* **Fazer's Universality**: Fazer abstracts the operating system. `ls()`, `rm()`, and `exec()` work identically on Windows, Linux, and macOS. Write once, control any system.
|
|
212
|
-
* **Safety**: Bash has no real error handling or types. A wrong variable expansion can delete your hard drive (`rm -rf /$VAR`). Fazer provides a structured, safe environment with scoped variables and error handling.
|
|
213
|
-
|
|
214
|
-
### 8.4. Fazer vs C/C++
|
|
215
|
-
|
|
216
|
-
* **Development Speed**: Writing a secure HTTP server with AES encryption in C++ takes days and hundreds of lines of code. In Fazer, it takes **5 lines**.
|
|
217
|
-
* **Memory Safety**: No manual memory management, no buffer overflows, no segmentation faults. Fazer handles the dirty work so you can focus on the logic.
|
|
218
|
-
|
|
219
|
-
### Summary Table
|
|
220
|
-
|
|
221
|
-
| Feature | Fazer | JavaScript | Python | Bash |
|
|
222
|
-
| :--- | :---: | :---: | :---: | :---: |
|
|
223
|
-
| **Pipeline Logic** | ✅ Native (`→>`) | ❌ (Plugins needed) | ❌ | ✅ (Pipes `|`) |
|
|
224
|
-
| **Distribution** | ✅ Single Binary | ❌ (Requires Runtime) | ❌ (Complex) | ✅ (Source only) |
|
|
225
|
-
| **Cryptography** | ✅ Built-in AES-256 | ⚠️ Module required | ⚠️ Module required | ❌ External tools |
|
|
226
|
-
| **Cross-Platform** | ✅ 100% | ✅ | ✅ | ❌ |
|
|
227
|
-
| **Setup Time** | ⚡ Instant | 🐢 Slow (npm install) | 🐢 Slow (pip install) | ⚡ Instant |
|
|
27
|
+
## Documentation
|
|
228
28
|
|
|
229
|
-
|
|
29
|
+
La documentation complète est disponible dans le dossier [`docs/`](./docs/README.md).
|
|
230
30
|
|
|
231
|
-
|
|
31
|
+
* [Guide de Démarrage](./docs/getting-started.md)
|
|
32
|
+
* [Syntaxe du Langage](./docs/syntax.md)
|
|
33
|
+
* [Bibliothèque Standard (Stdlib)](./docs/stdlib.md)
|
|
34
|
+
* [Exemples](./docs/examples.md)
|
|
232
35
|
|
|
233
|
-
|
|
234
|
-
Unauthorized reproduction of the core interpreter logic without attribution is prohibited.
|
|
36
|
+
## Fonctionnalités Clés
|
|
235
37
|
|
|
236
|
-
* **
|
|
237
|
-
* **
|
|
38
|
+
* **Pipe Operator (`->>`)** : Enchaînez les opérations proprement.
|
|
39
|
+
* **Pattern Matching (`case`)** : Contrôle de flux expressif.
|
|
40
|
+
* **Sécurité Intégrée** : Chiffrement AES-256-GCM et SHA256 natifs.
|
|
41
|
+
* **Réseau & Web** : Client HTTP `fetch`, serveur web `server`, et module `discord`.
|
|
42
|
+
* **Système de Fichiers** : Manipulation simple et puissante.
|
|
43
|
+
* **Automation** : Gestion du presse-papier (`clipboard`), menus interactifs, et persistance (`db`).
|
|
44
|
+
* **Extensible** : Système de modules `import`.
|
|
238
45
|
|
|
239
|
-
|
|
46
|
+
## Copyright
|
|
240
47
|
|
|
241
|
-
|
|
48
|
+
© 2024 **L'EMPRISE**. Tous droits réservés.
|
|
49
|
+
Distribué sous licence MIT.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Documentation Fazer
|
|
2
|
+
|
|
3
|
+
Bienvenue dans la documentation officielle du langage **Fazer**.
|
|
4
|
+
|
|
5
|
+
## Table des Matières
|
|
6
|
+
|
|
7
|
+
1. **[Guide de Démarrage](./getting-started.md)**
|
|
8
|
+
* Installation
|
|
9
|
+
* Votre premier script
|
|
10
|
+
* Mode interactif (REPL)
|
|
11
|
+
|
|
12
|
+
2. **[Syntaxe du Langage](./syntax.md)**
|
|
13
|
+
* Variables et Types
|
|
14
|
+
* Opérateur Pipe (`->>`)
|
|
15
|
+
* Contrôle de Flux (`case`)
|
|
16
|
+
* Fonctions
|
|
17
|
+
|
|
18
|
+
3. **[Bibliothèque Standard (Stdlib)](./stdlib.md)**
|
|
19
|
+
* E/S Console (`println`, `ask`...)
|
|
20
|
+
* Système de Fichiers (`readText`, `writeText`...)
|
|
21
|
+
* Chiffrement (`encText`, `sha256`...)
|
|
22
|
+
* Réseau & Web (`server`, `fetch`, `discord`...)
|
|
23
|
+
* Utilitaires (`json`, `exec`...)
|
|
24
|
+
|
|
25
|
+
4. **[Exemples](./examples.md)**
|
|
26
|
+
* Scripts complets pour apprendre par l'exemple.
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Exemples Fazer
|
|
2
|
+
|
|
3
|
+
## 1. Hello World
|
|
4
|
+
|
|
5
|
+
```fazer
|
|
6
|
+
"Hello World" ->> println
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 2. Demander le nom
|
|
10
|
+
|
|
11
|
+
```fazer
|
|
12
|
+
"Quel est votre nom ? " ->> ask ->> println
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 3. Chiffrement de Fichier (Logique simplifiée)
|
|
16
|
+
|
|
17
|
+
Ce script montre comment on pourrait structurer un outil de chiffrement.
|
|
18
|
+
|
|
19
|
+
```fazer
|
|
20
|
+
fn main () {
|
|
21
|
+
"1. Chiffrer" ->> println
|
|
22
|
+
"2. Déchiffrer" ->> println
|
|
23
|
+
"Choix : " ->> ask ->> case {
|
|
24
|
+
"1" : {
|
|
25
|
+
"Fichier à chiffrer : " ->> ask ->> enc_flow
|
|
26
|
+
}
|
|
27
|
+
"2" : {
|
|
28
|
+
"Fichier à déchiffrer : " ->> ask ->> dec_flow
|
|
29
|
+
}
|
|
30
|
+
_ : {
|
|
31
|
+
"Choix invalide" ->> println
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fn enc_flow (path) {
|
|
37
|
+
path ->> exists ->> case {
|
|
38
|
+
true : {
|
|
39
|
+
"Mot de passe : " ->> ask ->> pass
|
|
40
|
+
path ->> readText ->> encText(pass) ->> saveText(path)
|
|
41
|
+
"Fichier chiffré !" ->> println
|
|
42
|
+
}
|
|
43
|
+
_ : { "Fichier introuvable" ->> println }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Lancer le main
|
|
48
|
+
main()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 4. Serveur Web Simple
|
|
52
|
+
|
|
53
|
+
```fazer
|
|
54
|
+
fn handle_request (req) {
|
|
55
|
+
"<h1>Bienvenue sur Fazer Web</h1>" // Retourne le HTML
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
"Démarrage du serveur sur 8080..." ->> println
|
|
59
|
+
8080 ->> server("handle_request")
|
|
60
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Guide de Démarrage
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
La façon la plus simple d'installer Fazer est via NPM (Node Package Manager).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g fazer-lang
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Vérifiez l'installation :
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
fazer --version
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Votre Premier Script
|
|
18
|
+
|
|
19
|
+
Créez un fichier nommé `hello.fz` avec le contenu suivant :
|
|
20
|
+
|
|
21
|
+
```fazer
|
|
22
|
+
"Hello World!" ->> println
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Exécutez-le via la ligne de commande :
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
fazer hello.fz
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Vous devriez voir `Hello World!` s'afficher.
|
|
32
|
+
|
|
33
|
+
## Le Mode Interactif (REPL)
|
|
34
|
+
|
|
35
|
+
Si vous lancez `fazer` sans arguments, vous entrez dans le mode interactif. C'est idéal pour tester des petites lignes de code.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
$ fazer
|
|
39
|
+
Welcome to Fazer v2.2.1
|
|
40
|
+
> 10 ->> println
|
|
41
|
+
10
|
|
42
|
+
> "test" ->> sha256 ->> println
|
|
43
|
+
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Tapez `exit` ou faites `Ctrl+C` pour quitter.
|
package/docs/stdlib.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Bibliothèque Standard (Stdlib)
|
|
2
|
+
|
|
3
|
+
Fazer inclut une bibliothèque standard riche pour interagir avec le système, les fichiers, le réseau et plus encore.
|
|
4
|
+
|
|
5
|
+
## Entrées / Sorties
|
|
6
|
+
|
|
7
|
+
### `print(valeur)` / `println(valeur)`
|
|
8
|
+
Affiche une valeur sur la sortie standard (console).
|
|
9
|
+
|
|
10
|
+
### `input(message)`
|
|
11
|
+
Affiche un message et attend une entrée utilisateur (retourne une chaîne).
|
|
12
|
+
|
|
13
|
+
### `box(titre, contenu)`
|
|
14
|
+
Affiche une boîte stylisée avec un titre et du contenu (texte ou liste).
|
|
15
|
+
|
|
16
|
+
### `menu(options)`
|
|
17
|
+
Affiche un menu interactif dans la console et retourne l'option choisie.
|
|
18
|
+
```fazer
|
|
19
|
+
choix := menu(["Option A", "Option B"])
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### `style(texte, couleur)`
|
|
23
|
+
Applique une couleur ANSI au texte pour l'affichage console.
|
|
24
|
+
Couleurs : "red", "green", "blue", "yellow", "cyan", "magenta", "white", "bold", "dim".
|
|
25
|
+
```fazer
|
|
26
|
+
println(style("Succès !", "green"))
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Fichiers (File System)
|
|
30
|
+
|
|
31
|
+
### `read(path)`
|
|
32
|
+
Lit un fichier texte entier.
|
|
33
|
+
|
|
34
|
+
### `write(path, content)`
|
|
35
|
+
Écrit du contenu dans un fichier (écrase le fichier).
|
|
36
|
+
|
|
37
|
+
### `exists(path)`
|
|
38
|
+
Retourne `true` si le fichier ou dossier existe.
|
|
39
|
+
|
|
40
|
+
### `readBytes(path)` / `writeBytes(path, b64)`
|
|
41
|
+
Lecture/Écriture binaire (encodé en Base64).
|
|
42
|
+
|
|
43
|
+
### `import(chemin)`
|
|
44
|
+
Charge et exécute un autre script Fazer.
|
|
45
|
+
```fazer
|
|
46
|
+
import("utils.fz")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Système & Exécution
|
|
50
|
+
|
|
51
|
+
### `exec(cmd)`
|
|
52
|
+
Exécute une commande shell et retourne la sortie (stdout) sous forme de chaîne.
|
|
53
|
+
```fazer
|
|
54
|
+
files := exec("ls -la")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `notify(titre, message)`
|
|
58
|
+
Affiche une notification système (Windows Toast).
|
|
59
|
+
```fazer
|
|
60
|
+
notify("Fazer", "Tâche terminée avec succès !")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `clipboard`
|
|
64
|
+
Objet global pour interagir avec le presse-papier système.
|
|
65
|
+
* `clipboard.read()` : Retourne le contenu texte du presse-papier.
|
|
66
|
+
* `clipboard.write(texte)` : Écrit du texte dans le presse-papier.
|
|
67
|
+
|
|
68
|
+
### `sleep(ms)`
|
|
69
|
+
Met le script en pause pour `ms` millisecondes.
|
|
70
|
+
|
|
71
|
+
### `env(nom_var)`
|
|
72
|
+
Lit une variable d'environnement.
|
|
73
|
+
|
|
74
|
+
### `cwd()`
|
|
75
|
+
Retourne le dossier de travail actuel.
|
|
76
|
+
|
|
77
|
+
### `argv()`
|
|
78
|
+
Retourne les arguments de la ligne de commande.
|
|
79
|
+
|
|
80
|
+
## Réseau & Web
|
|
81
|
+
|
|
82
|
+
### `fetch(url, options)`
|
|
83
|
+
Effectue une requête HTTP. `options` est un objet (method, headers, body).
|
|
84
|
+
Retourne `{ status, body, headers }`.
|
|
85
|
+
|
|
86
|
+
### `server(port, handler)`
|
|
87
|
+
Démarre un serveur HTTP simple.
|
|
88
|
+
`handler` peut être une fonction qui prend `req` et retourne `res`, ou un objet de routage simple.
|
|
89
|
+
```fazer
|
|
90
|
+
fn handler(req) ->
|
|
91
|
+
"Hello from Fazer!"
|
|
92
|
+
end
|
|
93
|
+
server(8080, handler)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### `discord(token)`
|
|
97
|
+
Crée un client Discord (Bot).
|
|
98
|
+
* `.on("message", fn)`
|
|
99
|
+
* `.send(channelId, content)`
|
|
100
|
+
|
|
101
|
+
## Cryptographie
|
|
102
|
+
|
|
103
|
+
### `sha256(texte)`
|
|
104
|
+
Retourne le hash SHA-256 (hex).
|
|
105
|
+
|
|
106
|
+
### `encrypt(texte, mot_de_passe)`
|
|
107
|
+
Chiffre le texte avec AES-256-GCM (retourne Base64).
|
|
108
|
+
|
|
109
|
+
### `decrypt(b64, mot_de_passe)`
|
|
110
|
+
Déchiffre le texte.
|
|
111
|
+
|
|
112
|
+
## JSON & Données
|
|
113
|
+
|
|
114
|
+
### `json(obj)`
|
|
115
|
+
Convertit un objet en chaîne JSON.
|
|
116
|
+
|
|
117
|
+
### `parseJson(str)`
|
|
118
|
+
Parse une chaîne JSON en objet.
|
|
119
|
+
|
|
120
|
+
### `int(valeur)`
|
|
121
|
+
Convertit une valeur en entier.
|
|
122
|
+
|
|
123
|
+
### `float(valeur)`
|
|
124
|
+
Convertit une valeur en nombre flottant.
|
|
125
|
+
|
|
126
|
+
### `db(chemin_json)`
|
|
127
|
+
Crée ou charge une base de données JSON persistante.
|
|
128
|
+
Retourne un objet avec `.get(k)`, `.set(k, v)`, `.save()` et `.data()`.
|
|
129
|
+
```fazer
|
|
130
|
+
mydb := db("data.json")
|
|
131
|
+
mydb.set("score", 100)
|
|
132
|
+
mydb.save()
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `keys(obj)`
|
|
136
|
+
Retourne les clés d'un objet JSON.
|
|
137
|
+
|
|
138
|
+
### `get(obj, clé)`
|
|
139
|
+
Récupère une valeur dans un objet/map.
|
package/docs/syntax.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Syntaxe du Langage Fazer
|
|
2
|
+
|
|
3
|
+
Fazer est un langage orienté flux. La plupart des opérations se font de gauche à droite via l'opérateur pipe.
|
|
4
|
+
|
|
5
|
+
## Commentaires
|
|
6
|
+
|
|
7
|
+
```fazer
|
|
8
|
+
// Ceci est un commentaire sur une ligne
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Variables
|
|
12
|
+
|
|
13
|
+
Il n'y a pas de mot-clé de déclaration explicite comme `var` ou `let` pour l'assignation simple dans le flux, mais vous pouvez nommer des valeurs dans des arguments de fonctions.
|
|
14
|
+
|
|
15
|
+
Cependant, Fazer utilise principalement le passage de valeurs. Pour stocker des états globaux ou complexes, on utilise souvent des objets JSON ou la mémoire interne via `set`/`get`.
|
|
16
|
+
|
|
17
|
+
```fazer
|
|
18
|
+
// Exemple d'utilisation de set/get (mémoire clé-valeur)
|
|
19
|
+
"ma_valeur" "cle" ->> set
|
|
20
|
+
"cle" ->> get ->> println // Affiche "ma_valeur"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Opérateur Pipe (`->>`)
|
|
24
|
+
|
|
25
|
+
L'opérateur `->>` passe le résultat de l'expression de gauche comme **premier argument** de la fonction de droite.
|
|
26
|
+
|
|
27
|
+
```fazer
|
|
28
|
+
"Bonjour" ->> println
|
|
29
|
+
// Équivalent à println("Bonjour") dans d'autres langages
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Chaînage :
|
|
33
|
+
|
|
34
|
+
```fazer
|
|
35
|
+
"mot_de_passe" ->> sha256 ->> println
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Chaînes de Caractères et Nombres
|
|
39
|
+
|
|
40
|
+
```fazer
|
|
41
|
+
"Ceci est une chaîne"
|
|
42
|
+
123
|
|
43
|
+
12.34
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Fonctions (Définition)
|
|
47
|
+
|
|
48
|
+
Fazer supporte la définition de fonctions nommées.
|
|
49
|
+
|
|
50
|
+
```fazer
|
|
51
|
+
fn ma_fonction (arg1) {
|
|
52
|
+
arg1 ->> println
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
"test" ->> ma_fonction
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Contrôle de Flux : `case`
|
|
59
|
+
|
|
60
|
+
Fazer n'a pas de `if/else` traditionnel. Tout se fait via `case` (pattern matching).
|
|
61
|
+
|
|
62
|
+
```fazer
|
|
63
|
+
valeur ->> case {
|
|
64
|
+
"option1" : {
|
|
65
|
+
"C'est l'option 1" ->> println
|
|
66
|
+
}
|
|
67
|
+
"option2" : {
|
|
68
|
+
"C'est l'option 2" ->> println
|
|
69
|
+
}
|
|
70
|
+
_ : {
|
|
71
|
+
"Cas par défaut (wildcard)" ->> println
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Conditionnelle (If-Else simulé)
|
|
77
|
+
|
|
78
|
+
Pour faire un `if`, on matche souvent sur un booléen ou une valeur spécifique. Notez que Fazer évalue l'égalité stricte.
|
|
79
|
+
|
|
80
|
+
```fazer
|
|
81
|
+
// Exemple conceptuel
|
|
82
|
+
variable ->> case {
|
|
83
|
+
"vrai" : { ... }
|
|
84
|
+
_ : { ... }
|
|
85
|
+
}
|
|
86
|
+
```
|