1.3 KiB
1.3 KiB
Practical Scripting in Claro
Claro v1.10.26 includes simple commands that make small automation scripts possible.
Arguments
COUNT ARGUMENTS AS total
GET ARGUMENT 1 AS first
GET ALL ARGUMENTS AS args
Run with:
claro myscript.claro apple banana
Environment
GET ENV "PATH" AS path
SAY path
Folders and files
CREATE FOLDER "output"
WRITE FILE "output/hello.txt" WITH "Hello"
COPY FILE "output/hello.txt" TO "output/copy.txt"
MOVE FILE "output/copy.txt" TO "output/moved.txt"
LIST FOLDER "output" AS files
DELETE FILE "output/hello.txt"
DELETE FILE "output/moved.txt"
DELETE FOLDER "output"
Text helpers
TEXT UPPER "hello" AS loud
TEXT LOWER "LOUD" AS quiet
TEXT TRIM " neat " AS clean
TEXT LENGTH clean AS size
TEXT CONTAINS "hello world" NEEDLE "world" AS found
List helpers
SORT names
REVERSE names
FIND "Jon" IN names AS place
REMOVE "Jon" FROM names
External commands
RUN COMMAND "echo hello" AS output
SAY output
SAY LASTEXIT
Use this carefully. It runs commands on the user's computer.
RUN COMMAND is for trusted code only. It is not a sandbox: it can start programs, read or change files, and use the same permissions as the user running Claro. Do not run scripts from an untrusted source, and do not treat this feature as a security boundary.