Skip to content

Instantly share code, notes, and snippets.

@the-vampiire
Last active July 1, 2019 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-vampiire/a2ea2c94ff318162ac09ae0927111812 to your computer and use it in GitHub Desktop.
Save the-vampiire/a2ea2c94ff318162ac09ae0927111812 to your computer and use it in GitHub Desktop.
what do the command line notations mean

it can be frustrating but it was likely left out because writing a CLI is predicated by having seen this notation used in the documentation when using a CLI.

to answer your question though (and a bit extra because i was there once too):

when you see $ this is almost always used to indicate that everything after the $ is a single line to paste into the command line (shell) and hit enter. it will usually be in this general form

$ program command <required arg> [optional arg]

you will likely come across these two other symbols that confused me as well:

<> means this is a required argument for this command

[] means this is an optional argument for this command

and if you see a comma and / or ellipses it means multiple required / optional args:

$ program command <require arg(s), ...> [optional arg(s), ...]

and heres an example youll likely come across a lot to demonstrate:

$ git clone <source repo url> [/path/for/clone]

the source repo url is <required> and the path where the clone will be copied to is [optional] (defaulting the current working directory in your command line shell). you can view this with:

$ cwd

extra extra bit, if you see things like -a or --something these are called CLI flags. they are often used as modifiers for a certain command. heres an example thats useful to create and checkout a new git branch in one go:

$ git checkout -b <branch name>

where -b is a flag that modifies the checkout command of the git program that tells it to create the branch before checking it out

and the flag that will likely be most helpful for you in any case (most good CLIs will support this)

$ program --help
# or
$ program -help

cheers man good luck on the journey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment