liveBook · Manning

Command-line argument

A command-line argument is a value supplied to a program when it is invoked, either as positional input or as an option that configures its behavior.

How 14 Manning books explain it

The Quick Python Book, Fourth Edition

A command-line argument is a value supplied to a program when it is invoked through a command-line interface.

How it is used
Supplies runtime inputs and switches to Python command-line scripts, including file-processing utilities.
How deep it goes
Works through sys.argv strings, argparse positionals and options, parsing errors, and script-level validation; stops short of parser internals.
Examples
Demonstrates parsed options for a report script and filename-versus-redirected-input runs of a wc-style utility.
What you can do after
Apply it via sys.argv and argparse to receive, parse, and validate inputs for command-line scripts.

Read how The Quick Python Book, Fourth Edition explains command-line argument →

Go by Example

A command-line argument is a string value supplied to a program by the operating system when the program starts.

How it is used
Uses arguments to supply required CLI inputs and flags to configure HTTP request runs.
How deep it goes
Explains raw os.Args through FlagSet parsing, positional ordering, and custom value parsers.
Examples
Demonstrates HIT invocations with URL, request-count, and concurrency arguments, plus incorrect positional ordering.
What you can do after
Build it from scratch by reading argument strings, parsing flags, and retrieving positional inputs with FlagSet.

Read how Go by Example explains command-line argument →

Tiny Python Projects: Learn coding and testing with puzzles and games

A command-line argument is a value supplied to a program when it is launched from a command-line interface.

How it is used
Uses supplied values to make command-line programs configurable, documented, testable, and reusable without source edits.
How deep it goes
Explains parsing, help generation, positional and optional forms, and defaults, but stops short of parser internals.
Examples
Demonstrates greeting names, required and default values, help output, file inputs, and incremental tests.
What you can do after
Build it from scratch, define argparse parameters, run programs with values or flags, and test usage and input behavior.

Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains command-line argument →

Go in Practice, Second Edition

A command-line argument is a positional value supplied to a command-line program when it is invoked.

How it is used
Supplies positional operands to a command-line calculator.
How deep it goes
Shows positional access through a Cobra callback and numeric conversion, but does not show argument-count validation.
Examples
Uses an `add <number1> <number2>` calculator command and a Cobra help usage line ending in `[arguments...]`.
What you can do after
Apply it via Cobra to read positional operands and convert their numeric strings in a CLI calculator.

Read how Go in Practice, Second Edition explains command-line argument →

Learn Rust in a Month of Lunches

A command-line argument is a value supplied to a program when it is launched through a command-line interface.

How it is used
Uses launch-time input to let a Rust program respond to words supplied on the command line.
How deep it goes
Works through printing, skipping, and matching arguments in a small program.
Examples
Shows `cargo run` with extra words and a program that changes words to uppercase or lowercase.
What you can do after
Build it from scratch: read arguments with `std::env::args()`, skip the program name, and act on supplied words.

Read how Learn Rust in a Month of Lunches explains command-line argument →

Learn Haskell by Example

A command-line argument is a value supplied to a program when it is launched from a command-line interface.

How it is used
Configures command-line tools with input filenames and behavior-changing options.
How deep it goes
Explains `getArgs`, pure list parsing, pattern matching, typed options, and function selection; defers detail on `deriving`.
Examples
Uses an `nl <filename>` line-numbering tool with reverse, skip-empty, and left-align options.
What you can do after
Build it from scratch by reading arguments, parsing a filename and options, and selecting program behavior.

Read how Learn Haskell by Example explains command-line argument →

Modern C, Third Edition

A command-line argument is a string value supplied to a program when it is invoked from a command-line environment.

How it is used
Supplies values to a C program at invocation for interpretation through `main`.
How deep it goes
Defines `argc` and `argv`, identifies their special positions, and shows numeric decoding; leaves compiler translation mechanics aside.
Examples
Uses compiler invocation commands and a `strtod(argv[i], nullptr)` expression.
What you can do after
Apply it via `argc`, `argv`, and `strtod` to read an argument and interpret it as a double.

Read how Modern C, Third Edition explains command-line argument →

Modern C

A command-line argument is a text value supplied to a program when it is invoked.

How it is used
Communicates values from the command line to a C program through main.
How deep it goes
Explains argc, argv, special argv entries, and string-to-double decoding, while deferring broader pointer mechanisms.
Examples
Uses main prototypes and a numeric-input example that decodes argv strings as double values with strtod.
What you can do after
Apply it via main and strtod to receive command-line text and interpret selected arguments as double data.

Read how Modern C explains command-line argument →

Learn Go with Pocket-Sized Projects

A command-line parameter is an argument supplied to a program when it is invoked from a command-line interface.

How it is used
Deploys explicit user settings for CLI programs, including behavior flags, output choices, and positional input.
How deep it goes
Explains flag declaration, defaults, parsing order, positional retrieval, and missing-input handling, while deferring broader configuration mechanisms.
Examples
Uses language-selection flags, unsupported-language exercises, and currency conversion with source, target, and amount inputs.
What you can do after
Apply it via Go’s flag package to build CLIs that parse typed flags, read positional values, and report missing input.

Read how Learn Go with Pocket-Sized Projects explains command-line argument →

The Well-Grounded Rubyist, Fourth Edition

A command-line option that instructs the Ruby interpreter to perform an action or change its behavior.

How it is used
Uses interpreter arguments to check programs, enable warnings, execute snippets, inspect versions, and request help.
How deep it goes
Explains switch purposes and demonstrates inline execution, while stopping short of exhaustive switch reference.
Examples
Uses reversed-name scripts, syntax-check commands, warning flags, line mode, and version-check commands.
What you can do after
Operate/configure Ruby from a shell by selecting switches for checking, warnings, execution, output, version display, and help.

Read how The Well-Grounded Rubyist, Fourth Edition explains command-line argument →

.NET in Action, Second Edition

A command-line argument is a value supplied to a program when it is invoked from a command-line interface.

How it is used
Handles input and options for console applications that process text or files.
How deep it goes
Moves from argument conventions to parser-backed options and file-input handling, without detailing parser internals.
Examples
Uses ASCII-art text and font options, file searching, piped filenames, and short or long option forms.
What you can do after
Apply CommandLineParser to define required positional values and optional named options for a console application.

Read how .NET in Action, Second Edition explains command-line argument →

Go in Action, Second Edition

A command-line argument is a value supplied to a program when it is invoked from a command line or operating-system process launcher.

How it is used
Uses caller-supplied values to select files and configure command-line tools without changing program code.
How deep it goes
Explains os.Args indexing and validation, then extends the treatment to typed flags and remaining positional arguments.
Examples
Demonstrates filename-based word counting and a JSON/XML conversion tool accepting input and output files.
What you can do after
Build it from scratch by accepting, validating, parsing, and applying command-line values in Go programs.

Read how Go in Action, Second Edition explains command-line argument →

Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

A value supplied to a program when it is launched from a command line.

How it is used
Uses launch-time values to select robot targets, execute commands, or evaluate Python without editing application code.
How deep it goes
Defines the role and demonstrates uses, but does not show argument-parsing implementation details.
Examples
Demonstrates Python's -c option and a robot application receiving a target QR-code name.
What you can do after
Apply it via Python launches to evaluate code or direct a robot toward a selected QR-code destination.

Read how Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi explains command-line argument →

Shipping Go: Develop, deliver, discuss, design, and go again

A named command-line option that supplies a value or modifies a program's execution settings.

How it is used
Uses explicit runtime options to adjust server behavior without changing application code or rebuilding the service.
How deep it goes
Explains Go flag declaration, parsing, and precedence alongside files and environment variables, but does not develop broader command-line interface design.
Examples
Demonstrates --config_file and --port while comparing JSON-file, environment-variable, and flag values for a service port.
What you can do after
Operate/configure a Go service by supplying runtime flags that override file, environment, and default configuration values.

Read how Shipping Go: Develop, deliver, discuss, design, and go again explains command-line argument →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.