evoke Get started

Examples · 01 of 06

Your Mac does everyday things at a word.

Thirteen reflexes, installed with one line. Set the volume, turn Wi-Fi off, start a timer, lock the screen, draft a mail. Each is a small program with its manifest, and you can read every file. This example runs today, on a Mac.

The request and the result

01

Three sentences, three outcomes.

A volume change runs at once. A less certain one asks, and learns from your answer. A restart asks every time. Every line is what the terminal printed.

~
$ evoke "restart the computer" power action="restart" · destructive · weakest: action 0.97 Really restart now? [y]es [n]o [t]each > n [2]
  1. 1Sure enough, so it ran. «40 percent» is a number read from the sentence and checked against the range 0 to 100. At 0.93, over the write bar of 0.8, nothing asked.
  2. 2«kill» meant off at only 0.72. Under the bar, so evoke asked. Typing t recorded the phrase in your overlay, then ran. The next time, it is sure.
  3. 3Sure at 0.97, and it still asked. A restart is destructive. No number and no flag skips that question. [2] means you said no.

The operations

02

A manifest and a body, per reflex.

This is volume, one of the thirteen. The manifest says what it does and what it asks. The body is thirty lines that run one AppleScript line. The other twelve look the same.

volume/reflex.tomlthe collection's
reflex = 1

description = """
Set the output volume.
A percentage of the maximum; 0 is silent."""

not_for = ["muting and unmuting", "screen brightness", "one app's volume"]
tags    = ["sound"]
effect  = "write"
confirm = "Set the volume to {level}?"
run     = "volume.mts"

[args.level]
ask   = "How loud, in percent?"
pick  = "number"
range = [0, 100]

[examples]
"set the volume to 40 percent" = { level = "40 percent" }
"volume 15"                    = { level = "15" }
"turn the sound up to 80"      = { level = "80" }

[tests]
"make it 100 percent loud"   = { level = "100 percent" }
"turn the volume down a bit" = { level = false }
"mute the sound"             = false
"set the brightness to 50"   = false
  1. 1The manifest is the whole interface. A description, the near misses, one input read as a number with a range, and the sentences that teach.
  2. 2The body says no to another platform first. Then it runs osascript and returns one line. A body that fails prints why, and exits 1.
  3. 3Three reflexes wait for your words. open, visit and note stay inactive until a folder, a site or a file is named. The other ten work at once.

The thirteen, in one table: The collection →

One boundary

03

A value outside its range never reaches the program.

The manifest gives level a range of 0 to 100. A sentence can choose a value. It cannot make one up, and it cannot push one past its range.

evoke
$ evoke "set the volume to 150 percent"
  How loud, in percent?  150 percent is outside 0–100  > 40
  volume level="40"  0.93
volume 40%

evoke asked the input's own question, with the reason on the line. The answer was checked the same way. Ask, in the manual →

Before you run it

04

What this example needs.