liveBook · Manning

Command-line interface

As explained in Learn Haskell by Example

A command-line interface is a text-based interface in which users interact with programs by entering commands.

A command-line interface is a text-based way to run programs by entering commands in a terminal. It supports practical tools, scripts, and programs that communicate through textual input and output. section 3.0 section 1.4

Command-line programs become more useful when they:

  • Connect through pipelines, using the pipe symbol to pass one program’s text output into another program. section 3.0
  • Accept options such as a host, port, identifier, or text value through an argument parser. section 17.3.2
  • Organize related actions as commands, such as listing entries, adding entries, and toggling entries. section 17.3.2

A line-numbering tool

The Unix command `nl testFile.txt` prints a text file with numbered lines. Its output can be piped into search and filtering tools to locate matching source-code references or produce ordered listings. section 3.0

Figure 3.1 An example of how to transform data using pipes with shell commands
figure

Follow the pipeline diagram to see how shell commands transform and pass data between processes. section 3.0

How Learn Haskell by Example covers it

How deep it goes
Explains pipelines, options, subcommands, and typed parsers through implementation examples rather than terminal internals.
Examples
Uses the `nl` utility, shell pipelines, Git-style subcommands, and a todo-list client with list, add, and toggle commands.
What it assumes
Assumes basic Haskell and GHCi experience while introducing operating-system interaction and command-line parsing through projects.
What you can do after
Builds command-line programs that parse options and subcommands, perform input/output, and communicate with other processes.
How it connects
Connects shell pipelines with input/output, side effects, argument parsing, and statically typed client-server data.

Also explained in

Compare how 9 books explain command-line interface →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.