Chapter 11 of 14

Terminal and automation

A Creole program can receive terminal inputs, run trusted commands, download files, and work with archives.

Receive program inputs

Run a file with extra values:

creole report.crlo reports daily

Read them in the program:

Use first argument as folder.
Use second argument as mode.
Show argument count.
Show folder.
Show mode.

Give each argument a clear name before using it.

Run a trusted command

Run command "echo Hello" as result.

If result's successful.
  Show result's output.
Else.
  Show result's error.
End.

A command result lets the program check success and read its output.

Never build a command directly from untrusted user input. Validate every value first.

Download a file

Download address to file "download.zip" with limit 20 MB.

A size limit protects the program from unexpectedly large downloads. Use trusted HTTPS addresses.

Create and extract archives

Zip folder "reports" to file "reports.zip".
Extract zip "reports.zip" to folder "restored".

Use a separate destination when testing extraction so existing files are not replaced accidentally.

Wait between actions

Show "Starting".
Wait 500ms.
Show "Half a second passed".
Pause for 2s.
Show "Finished".

Use waits only when the program truly needs a delay.

Stop a program

Show "Work complete".
Stop.

Stop! is also available when the instruction should read as immediate.

Automation safety

  • Run only commands you understand.
  • Validate terminal arguments.
  • Keep downloads limited.
  • Use temporary folders while testing.
  • Back up important files before automation changes them.
  • Check command results instead of assuming success.

Learning checklist

  • I can read terminal arguments.
  • I can check a command result.
  • I can limit a download.
  • I can create and extract a ZIP file.
  • I can add a controlled delay.
  • I validate untrusted input.

Next step

Continue to Mathematics to calculate values with readable words and compact math.