-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOMMANDS.txt
More file actions
271 lines (230 loc) · 5.79 KB
/
COMMANDS.txt
File metadata and controls
271 lines (230 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
GdPy command list
=================
GdPy is a small scripting language on top of Python.
Main feature update:
- Expressions now work inside SET, for example: SET total = a + b
- You can import installed Python modules: IMPORT math, IMPORT random AS rnd
- The language now supports IF/ELSE/ENDIF, WHILE, FOR, files, JSON, strings and collections
- Added script-style commands: IMPORT python, IMPORT rights, IMPORT error, ERROR(on/off), RIGHTS(give), ENTER, CLOSE, END()
- Added more system-style commands: CLEAR console, CLEAR = vars, ERROR(custom/clear), desktop imports, KILLPID, DOGFUNNY, SCREENSHOT, SAVE, chained actions with AND
Run:
python gdpy.py example.gdpy
Important notes
---------------
1. Files must use the .gdpy extension.
2. Lines starting with # are comments.
3. Variables can be inserted in text as {name} or $name.
4. Expressions use Python-like syntax: + - * / % ** comparisons, lists, dicts, function calls.
5. IMPORT works with Python modules already installed in your environment.
Command families and aliases
----------------------------
SAY:
SAY, PRINT, ECHO, WRITE, OUT, TELL, SHOW, DISPLAY, SPEAK
Syntax: SAY "text" | SAY a + b
SET:
SET, LET, VAR, MAKE, STORE, PUT, ASSIGN, VALUE
Syntax: SET name = expression
DEL:
DEL, UNSET, DROP, ERASE, CLEARVAR, REMOVEVAR
Syntax: DEL name
COPY:
COPY, CLONE, DUP, DUPLICATE, MIRROR
Syntax: COPY target = expression
SWAP:
SWAP, EXCHANGE, FLIP, ROTATEPAIR
Syntax: SWAP left right
TYPEOF:
TYPE, TYPEOF, KIND, WHATIS, VARTYPE
Syntax: TYPEOF target = expression
Math update:
ADD, PLUS, INCREASE, INC, SUMUP, BOOST
SUB, MINUS, DECREASE, DEC, REDUCE, LOWERBY
MUL, TIMES, MULTIPLY, SCALE, GROWBY
DIV, DIVIDE, SPLITBY, SHAREBY
MOD, REM, REMAINDER
POW, POWER, EXPONENT
Syntax examples:
ADD total 5
SUB total other
MUL total 2
DIV total 4
MOD total 3
POW total 2
Length:
LEN, LENGTH, SIZE, COUNT, COUNTAS
Syntax: LEN target = expression
Collections:
APPEND, PUSH, ADDITEM, PUTLAST
EXTEND, MERGE, CONCATLIST, JOINLIST
INSERT, PUTAT, ADDAT
REMOVE, TAKEOUT, DELITEM, DISCARD
POP, PULL, TAKEPOP, LASTOUT
CLEAR, EMPTY, WIPE, RESETLIST
SORT, ORDER, ARRANGE
REVERSE, FLIPLIST, BACKWARD
UNIQUE, DEDUP, DISTINCT
String tools:
SPLIT, TOKENS, CHOP, WORDSPLIT
JOIN, GLUE, CONCAT, STITCH
REPLACE, SWAPTEXT, CHANGE
UPPER, CAPS, BIGTEXT
LOWER, SMALL, LOWTEXT
STRIP, TRIM, CLEAN
Files:
READFILE, LOADFILE, OPENFILE, GETFILE
WRITEFILE, SAVEFILE, CREATEFILE, PUTFILE
APPENDFILE, ADDFILE, EXTENDFILE
EXISTS, FILEEXISTS, PATHHAS
MKDIR, CREATEDIR, NEWDIR
LISTDIR, DIRFILES, SHOWDIR, SCANDIR
READJSON, LOADJSON, OPENJSON
WRITEJSON, SAVEJSON, STOREJSON
Libraries and calls:
IMPORT, USE, MODULE, LOADLIB, REQUIRE
CALL, INVOKE, APPLY, RUNFUNC, EXECFUNC
Special imports:
IMPORT python enables direct Python lines in the script
IMPORT rights enables rights variable workflow
IMPORT error enables error variable workflow
IMPORT file placeholder, planned feature for system file browsing with rights
IMPORT desktop enables desktop/system info workflow
IMPORT desktop-time writes current desktop time into desktop-time and desktop_time
IMPORT desktop-data writes current desktop date into desktop-data and desktop_data
IMPORT killpid enables KILLPID capability, requires rights == yes
IMPORT dogfunny enables DOGFUNNY
IMPORT screenshot enables SCREENSHOT capability, requires rights == yes
Flow control:
LABEL, MARK, TAG, SIGNPOST
GOTO, JUMP, GO, MARKTO
IF, WHEN
ELIF
ELSE, OTHERWISE
ENDIF, FI, ENDWHEN
WHILE, LOOPWHILE
ENDWHILE, WEND, LOOPEND
FOR, EACH, FOREACH
ENDFOR, NEXT, ENDEACH
BREAK, STOPLOOP, LEAVELOOP
CONTINUE, NEXTLOOP, SKIPLOOP
Validation and utility:
ASSERT, ENSURE, VERIFY, CHECK
WAIT, SLEEP, PAUSE, DELAY
ASK, INPUT, READ, PROMPT, QUESTION
HELP, COMMANDS, MANUAL, DOCS
DUMP, VARS, STATE, CONTEXT
NOW, NOWTIME, TIMENOW
TODAY, DATE, DATEONLY
ERROR, ERRORMODE, ERRORS
RIGHTS, ADMIN, ELEVATE
ENTER, PAUSEENTER
NOP, PASS, REM, COMMENT, DO, SKIP, NOSTOP
END, STOP, EXIT, QUIT, HALT, FINISH, CLOSE
SAVE
SCREENSHOT
KILLPID
DOGFUNNY
Core syntax examples
--------------------
Variables and expressions:
SET a = 10
SET b = 20
SET total = a + b
SET data = {"name": "GdPy", "level": 2}
SET items = [1, 2, 3]
Conditions:
IF total > 10 THEN SAY "big"
IF total > 10
SAY "big"
ELSE
SAY "small"
ENDIF
Python-like style with colon:
IF total > 10:
SAY "big"
ELIF total == 10:
SAY "equal"
ELSE:
SAY "small"
ENDIF
Loops:
SET count = 3
WHILE count > 0
SAY count
SUB count 1
ENDWHILE
FOR item IN ["a", "b", "c"]
SAY item
ENDFOR
Libraries:
IMPORT math
SET root = math.sqrt(81)
SAY root
Direct Python mode:
IMPORT python
numbers = [x * 2 for x in range(5)]
print(numbers)
Error mode:
IMPORT error
ERROR(off)
SET a = 10
DIV a 0
SAY "script still works"
ERROR(on)
Custom error flag:
IMPORT error
ERROR(custom)
ERROR(off)
SET a = 10 / 0
IF error == yes:
SAY "error happened"
ENDIF
ERROR(clear)
Clear console and variables:
CLEAR
CLEAR = error, a, b
Desktop info:
IMPORT desktop-time
IMPORT desktop-data
SAY "{desktop-time}"
SAY "{desktop-data}"
Funny command:
IMPORT dogfunny
DOGFUNNY
Chained actions:
CLEAR and a = "Dog" and SAY a
Rights mode:
IMPORT rights
RIGHTS(give)
IF rights == no:
SAY "Admin rights were denied"
ELSE rights == yes:
SAY "Admin rights were accepted"
ELIF:
SAY rights
ENDIF
Files:
WRITEFILE "note.txt" WITH "hello"
READFILE text = "note.txt"
SAY text
JSON:
SET user = {"name": "GdPy", "score": 10}
WRITEJSON "user.json" WITH user
READJSON loaded = "user.json"
SAY loaded["name"]
Strings:
SET text = " hello,world "
STRIP clean = text
SPLIT parts = clean BY ","
JOIN line = parts BY " | "
SAY line
Example scripts in this project
-------------------------------
example.gdpy
examples/arithmetic.gdpy
examples/libraries.gdpy
examples/collections.gdpy
examples/control_flow.gdpy
examples/files_json.gdpy
examples/strings.gdpy
examples/rights_error.gdpy
examples/system_fun.gdpy