Run an approved command
Build a one-program catalogue for your own tool, feed it stdin, read the result, and meet both ways Cuprum refuses a program.
A job sheet for each job: the problem, complete code, the output it prints, and what happens when it fails.
Featured · Job sheet 001
Build a one-program catalogue for your own tool, feed it stdin, read the result, and meet both ways Cuprum refuses a program.
WC = Program("wc")
CATALOGUE = ProgramCatalogue.from_programs(WC, name="word-count")
count_words = sh.make(WC, catalogue=CATALOGUE)
def word_count(text: str) -> int:
cmd = count_words("-w")
with scoped(catalogue=CATALOGUE):
result = cmd.run_sync(stdin=StdinInput(text=text))
if not result.ok:
msg = f"wc failed with exit code {result.exit_code}: {result.stderr}"
raise RuntimeError(msg)
return int((result.stdout or "").strip())
The cabinet
A sheet is published once its code and expected output have been run against the pinned release.
Build a one-program catalogue for your own tool, feed it stdin, read the result, and meet both ways Cuprum refuses a program.
Compose two stages with |, tee the output to the terminal while capturing it, and read which stage failed when fail-fast stops the rest.
Working directory, environment overlays, a timeout, and cleanup, all under one narrowed scope.
Hooks, structured events, and the opt-in GitHub Actions sink that folds each run into a log group.
Bounded concurrency with run_concurrent, fail-fast or collect-all, and inspecting every result.