CommandlineConverter class

Command-line string parsing utilities.

This module provides functionality to parse command-line strings into individual argument components, handling quotes and escaping properly. Converts a command-line string into a list of individual arguments.

This converter handles quoted arguments and properly splits command lines while respecting shell quoting rules.

Supports:

  • Single quotes ('): Preserves content literally
  • Double quotes ("): Preserves content literally
  • Space separation: Splits arguments on unquoted spaces
  • Empty arguments: Handles quoted empty strings

Example:

final converter = CommandlineConverter();

// Simple command
final args1 = converter.convert('dart --version');
// Result: ['dart', '--version']

// Command with quoted arguments
final args2 = converter.convert('echo "hello world" \'single quoted\'');
// Result: ['echo', 'hello world', 'single quoted']

// Complex command with parameters
final args3 = converter.convert('flutter build apk --target-platform android-arm64');
// Result: ['flutter', 'build', 'apk', '--target-platform', 'android-arm64']
Inheritance

Constructors

CommandlineConverter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

bind(Stream<String> stream) Stream<List<String>>
Transforms the provided stream.
inherited
cast<RS, RT>() Converter<RS, RT>
Provides a Converter<RS, RT> view of this stream transformer.
inherited
convert(String? input) List<String>
Convert a command-line string into a list of arguments.
override
fuse<TT>(Converter<List<String>, TT> other) Converter<String, TT>
Fuses this with other.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startChunkedConversion(Sink<List<String>> sink) Sink<String>
Starts a chunked conversion.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited