Command-line interface
Интерфейс командной строки
A command-line interface (CLI) lets you use a program by typing commands instead of clicking buttons or menus. You can run the same commands from a script to automate a task.
Also known as: CLI, терминал, консоль
What a CLI is
A CLI is the set of commands and options a program gives you to work with it from the command line. For example, git status checks the state of a repository without opening a graphical Git client. The CLI is how you ask Git to do the work, not the window where you type the request.
That window is usually a terminal emulator: it accepts keyboard input and displays output. Inside it, a shell such as Bash reads the command line. The shell may handle a command itself, as it does with cd, or start an external program such as Git. People sometimes call the terminal window a console, but the word also refers to other interfaces, such as a browser's developer console. A script can use a CLI with no terminal window at all.
What happens when you run a command
In git log -n 3, git names the program, log selects a subcommand, and -n 3 asks for at most three commits. The shell parses the command line and passes the arguments to Git; Git decides what those arguments mean. In Bash, quotes keep a path with spaces together, so git diff -- "release notes.md" passes the filename as one argument rather than two.
A command can read data from standard input (stdin), write its results to standard output (stdout), and send diagnostics to standard error (stderr). It also reports an exit status when it finishes. Zero conventionally means success; the command's documentation tells you what its nonzero statuses mean. A command can succeed without printing anything, so output alone isn't a reliable success check.
Example: feed one command's output into another
Run this in Bash from a Git repository with at least one commit:
git log -n 3 --oneline | wc -l
Git prints one line per commit, up to three. The pipe (|) connects Git's standard output to the standard input of wc -l, which counts those lines. The pipe is shell syntax, not a Git option. It doesn't normally carry Git's standard error, so diagnostics can still appear in the terminal instead of being counted.
Where it matters on the job and in interviews
Developers use CLIs to install dependencies, run tests, and build projects. The same test command can run on a laptop and in CI. When moving it into automation, check what the command assumes: a relative path depends on the working directory, and a prompt that is easy to answer locally may block an unattended job.
An interviewer might ask what changes when you replace a pipe with > results.txt. The pipe sends output to another command; > writes it to a file, creating it or truncating it before the command runs. A common Bash follow-up is what happens if the first command in a pipeline fails. By default, the pipeline reports the last command's status, so a successful wc can hide a failed git log. Bash's pipefail option makes a failure earlier in the pipeline affect its exit status.