Skip to content

Someone Else's Machine

You'll turn a script that only works on your machine into a tool with arguments, a help flag and sane exit codes, then watch a friend run it cold.

About

A script that only works on your machine is a note to yourself. One that works on someone else's is a tool. That means arguments instead of hardcoded paths, a help flag that explains itself, exit codes so other scripts can tell when it failed, and no assumptions about what's installed. Coding next door has the API client and the published package. This one is the chore script you already have, made safe to hand over. The test is simple: hand it to a friend and watch them run it without asking you anything.

At a glance

Per requirement
25 XP
Completion bonus
150 XP
Requirements
6
Takes
Two weekends
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
With other people
Locked for now
Earn two more Common badges in Automation & Scripts to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Take a script you use and replace every hardcoded path with an argument or a config file. There should be no home folder path anywhere in the file. Paths come from arguments, a config file next to the script, or environment variables. Take a screenshot of the diff. Photo
  2. 2
    Add a help flag with a one-line description, every option, and an example. Use argparse in Python, getopts in bash or Commander in Node. Someone who has never seen the script should understand it from the help text alone. Take a screenshot of the help output. Photo
  3. 3
    Return exit code 0 on success and non-zero on every failure, with the error on stderr. A missing file, a bad argument and the network being down should each get a message and a non-zero exit. Check with echo $? after a failed run. Take one terminal screenshot showing the three failures and their codes. Photo
  4. 4
    Check for dependencies on start and say which one is missing. If it needs ffmpeg and ffmpeg isn't there, say so on line one instead of crashing on line forty. Take a screenshot of the message on a machine without the dependency. Photo
  5. 5
    Add a dry-run flag that prints what would happen and changes nothing. Anyone who moves or deletes files will want this before they trust your script. Take a screenshot of a dry run next to the real run. Photo
  6. 6
    Hand it to someone and watch them run it without asking you a single question. Send the file and nothing else. Sit next to them or on a call, and don't speak, because every question they ask is a bug in your help text. Film their first run, and list what they asked. Video