Command Line Interface (CLI),
a means of a user, agent or client, interacting with a computer program in form of plain text- or command lines. Programs are either the operating system, their command-line shells, or application software, for instance chess programs.
The CLI has its origins in teletype and later computer terminals to act as a system console and sequential input- and output device, where the program prompts for input, that is, prints a message or symbol on the teletype printer to indicate readiness for user input, and acts upon command lines as they are entered.
Unix and its composable design and philosophy originated by Ken Thompson was summarized by Doug McIlroy, contributor to Unix pipes : Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
Shell and Applications
Operating systems such as MS-DOS, Unix or Linux per default provide a shell as CLI, such as Command.com or Unix shell. Modern desktop versions of Windows use the Windows shell which is a graphical user interface, but include a command prompt window for console applications. Most operating systems support inter-process communication with standard streams or named pipes and are able to redirect standard streams from and to other processes. Command line interfaces are therefor often preferred by advanced users or software developers, as they provide a more concise and powerful way to control a program or operating system, and are generally easier to automate via scripting .
Text commands as entered via the keyboard, are a sequence of ASCII- or Unicode characters finally confirmed and send to the programs standard input by typing the Enter key, which is typically encoded at the end of the command string as newline character ("\n") (Posix) or a sequence of carriage return ("\r") and newline under Windows . Syntax and semantics of commands and their required or optional arguments depend on the OS or application of course, its state or mode. When the command is parsed, interpreted and executed, acknowledgments, results or answers are send back for a communication according to a protocol.
CLI and Chess Engines
Most current chess engines are implemented as console application to communicate via a command line interface. This is the most portable way, supported by all common operating systems, programming languages and their standard libraries. A proprietary chess engine interface for direct console play may be implemented by printing an ASCII-board and the game record, and prompting for a move or command, also streaming the iterative "thinking process", i.e. formatted text lines with score, depth, and principal variation to the console.
Pondering and the need to enter moves and commands even if the program is "thinking", requires an interruptible search routine. In single tasking operating systems like MS-DOS, engines often used coroutines to implement internal context switching between search and user interaction. Today, it is more common to rely on multithreading abilities of modern operating systems, and to use an explicit I/O-thread, while the search routine is regularly pondering whether it needs to be interrupted by pending input received by another thread, with the option to asynchronously stop the search.
The UNIX paradigm was further archetype of both primary protocols in computer chess, to communicate with a GUI or game playing controller or server - the Chess Engine Communication Protocol, and UCI. In conformance with these chess communication protocols, engines standard streams are redirected and controlled by a parent process such as the chess GUI, a game- or match controller like Cutechess-cli for automatic engine-engine matches , or their proxies inside a computer network.
- ASCII Diagrams
- CHEKMO-II on a PDP-8 (Video)
- Chess Game
- Entering Moves
- Graphical User Interface
- Kiwi for Win98 and input-reading stuff by Alessandro Scotti, CCC, September 29, 2004 » Kiwi, Windows, C++, Thread
- Safe I/O (repeated) by Fabien Letouzey, Winboard Forum, February 11, 2005
- Cutechess-cli: A command line tool for engine-engine matches by Ilari Pihlajisto, CCC, March 16, 2009
- Ponder console input move problem by Vlad Stamate, CCC, April 28, 2010 » Pondering
- Bash script to start UCI engine and get evaluation by Scott O'Nan, CCC, December 25, 2013
- how to probe egtb from console? by Marco Belli, CCC, May 15, 2015 » Endgame Tablebases
- command line engine match? by Erin Dame, CCC, November 06, 2016
- Command-line interface from Wikipedia
- List of command-line interpreters from Wikipedia
- Redirection from Wikipedia
- Shell (computing) from Wikipedia
- Command Prompt from Wikipedia