Start with the tool’s own help
A command-line tool is a program you run by typing a command in a terminal. Its help text is often the quickest way to learn what it accepts. Many tools support --help or -h. Try a help option before guessing how to use an unfamiliar command. The help screen commonly lists a short description, usage examples, available flags, and explanations of required inputs.
To follow the examples here, you need a terminal and Python 3.8 or newer; no extra packages are required. On macOS or Linux, try python3 --version and python3 --help. On Windows, open PowerShell and try py -3 --version and py -3 --help. If one of those commands is not found, check how Python is installed and launched on your computer before continuing. The examples below use python3; replace it with py -3 if that is your working command.
Help conventions are useful, but they are not universal. Some programs use help as a subcommand, such as tool help, while others provide separate help for each subcommand. If a command fails, read its message: it may show the correct spelling or suggest a help option. You can also look for words such as “usage,” “options,” and “arguments” to orient yourself in a long help screen.
Read flags and arguments as separate pieces
A flag changes how a command behaves. Flags commonly begin with one dash for a short form, such as -h, or two dashes for a long form, such as --help. Some flags are switches: their presence turns a behavior on. Others need a value, such as --name Ada. An argument without a flag name is often called a positional argument. The tool’s help text should tell you which inputs are required and which are optional.
Spaces separate words in most command shells. If one value contains spaces, quote it so the program receives it as one argument: --name "Ada Lovelace". Pay attention to where a value belongs. In usage text, square brackets often indicate an optional item, while an item without brackets is often required. These are common documentation conventions rather than rules enforced by every tool.
When learning a command, begin with the smallest useful invocation. Add one flag at a time and compare the output. This makes it easier to identify which option changed the result. Avoid copying a long command you do not understand, especially if it could modify or delete files.
Try a small command of your own
Create a file named greet.py in a folder you can find from your terminal. Enter this Python 3 code, preserving its line breaks and indentation: import argparse parser = argparse.ArgumentParser(description="Print a greeting") parser.add_argument("--name", required=True, help="Name to greet") parser.add_argument("--shout", action="store_true", help="Use uppercase") args = parser.parse_args() message = f"Hello, {args.name}!" if args.shout: message = message.upper() print(message)
From that folder, run python3 greet.py --help. Python’s argparse module generates a help screen from the options defined in the file. Next try python3 greet.py --name Ada, followed by python3 greet.py --name "Ada Lovelace" --shout. Here, --name takes a value; --shout is a switch and takes no value. If you are using Windows with the Python launcher, substitute py -3 for python3 in each command.
Finally, try python3 greet.py without --name. The program should explain that a required argument is missing. An unrecognized flag, such as --unknown, also produces an error. These failures are useful practice: they show how a tool communicates a problem before you use commands with more consequential effects.
Check what the exit code means
After a command finishes, it returns an exit code to the shell. By convention, zero means success, and a nonzero value means something went wrong or the requested work did not complete. The exact meaning of a particular nonzero number depends on the program, so consult its documentation rather than assuming all tools assign the same meanings.
Run python3 greet.py --name Ada, then immediately run echo $? in a macOS or Linux shell to see the previous command’s exit code. In Windows PowerShell, run $LASTEXITCODE instead. Repeat after running python3 greet.py without --name. For this script, argparse uses exit code 2 for an argument error, while a normal greeting exits with 0. The help option also exits successfully.
Check the code immediately: running another command can replace the status you meant to inspect. Exit codes become especially helpful in scripts, where one command can decide whether to continue based on whether another succeeded. For everyday troubleshooting, read both the error message and the exit code. The message usually explains what to fix; the code provides a compact success-or-failure signal.



