Command-line argument
A command-line argument is a value or option supplied to a program when it is invoked, providing input or affecting its behavior.
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
- Uses arguments and options to supply script inputs, select behavior, and provide a simple command-line interface.
- How deep it goes
- Works through raw argument access, parser configuration, type conversion, defaults, errors, and application-level handling.
- Examples
- Demonstrates a script printing sys.argv and a wc-style utility with count-selection options.
- What you can do after
- Apply it via argparse to configure positional inputs, options, conversions, defaults, and usage messages.
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.
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.
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
- Introduces command-line arguments as user input supplied before a program runs.
- How deep it goes
- Explains access, iteration, skipping the program name, and matching string arguments in a worked Rust program.
- Examples
- Uses uppercase and lowercase word conversion and the `--open` option of `cargo doc` as examples.
- What you can do after
- Apply Rust's std::env::args() to inspect and process user-supplied strings.
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
- Uses command-line arguments to supply values to programs and options to compiler invocations.
- How deep it goes
- Explains the main interface, special argv entries, and string conversion, without detailing command-line parsing.
- Examples
- Illustrates a compiler command and conversion of an argv entry to double with strtod.
- What you can do after
- Understand how to access command-line strings and interpret them as double values with strtod.
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.
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.
Systems Programming with Zig
A command line argument is a value supplied to a program when it is invoked from a command-line interface.
- How it is used
- Passes file paths to a cat-like utility so it can concatenate multiple files.
- How deep it goes
- Shows argument acquisition, skipping the executable name, and iterating paths, without demonstrating named-option parsing.
- Examples
- Demonstrates concatenating meow.txt and woof.txt and configuring reader and writer buffer sizes.
- What you can do after
- Apply it via Zig's std.process.Init to read file paths and iterate over them in a utility.
Read how Systems Programming with Zig 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.
Also covered in
- Build and Orchestrator in Go (From Scratch)
- Learn AI-Assisted Python Programming, Second Edition
- Python How-To
- Grokking Simplicity
- Logs and Telemetry
- Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
- Django in Action
- Rust Web Development
- Build Applications with Local AI Models on a Mac
- Kubernetes in Action, Second Edition
- Python Workout: 50 ten-minute exercises
- Road to Kubernetes
What to know first
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- applicationAn application is a software program or system that provides functionality or performs tasks for users or other software.
- JSONJSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
Related concepts
- callused by · A call is an invocation that requests execution of a function, routine, command, or tool, optionally supplying arguments.
- inputcontrasts with · An input is information, a value, or an action supplied to a system, program, or computation for processing or to influence its behavior.
- IntoIteratorimplements · IntoIterator is a Rust standard-library trait that defines how a value is converted into an iterator over its items.
- lsused by · ls is a command-line utility that lists files and directories in a filesystem directory.
Questions about command-line argument
What is command-line argument?
A command-line argument is a value or option supplied to a program when it is invoked, providing input or affecting its behavior.
Which Manning books explain command-line argument?
The Quick Python Book, Fourth Edition, Go by Example, Tiny Python Projects: Learn coding and testing with puzzles and games, Go in Practice, Second Edition, Learn Rust in a Month of Lunches, Learn Haskell by Example, Modern C, Third Edition, Modern C and 7 more.
What should I know before learning command-line argument?
Manning books that teach command-line argument usually introduce function, string, application and JSON first.
What is the difference between command-line argument and input?
A command-line argument is a value or option supplied to a program when it is invoked, providing input or affecting its behavior. An input is information, a value, or an action supplied to a system, program, or computation for processing or to influence its behavior.
What is command-line argument also called?
Command-line argument is also called command-line flag, command-line option, command-line parameter, CLI arguments or command-line switches.
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.














