shell library

Classes

ProcessCmd
Process command
Shell
Multiplatform Shell utility to run a script with multiple commands.
ShellEnvironment
Shell modifiable helpers. should not be modified after being set.
ShellEnvironmentAliases
Shell environment aliases for executable
ShellEnvironmentPaths
Shell environment ordered paths helper. Changes the PATH variable
ShellEnvironmentVars
Shell environment variables helper. Does not affect the PATH variable
ShellLinesController
Basic bi-directionnal shell lines controller.
ShellOptions
Shell options.

Extensions

ProcessRunProcessExt on Process
Process helper.
ProcessRunProcessResultExt on ProcessResult
run response helper.
ProcessRunProcessResultsExt on List<ProcessResult>
run response helper.

Constants

dartChannelBeta → const String
Beta channel.
dartChannelDev → const String
Dev channel.
dartChannelMaster → const String
Master channel.
dartChannelStable → const String
Stable channel.

Properties

dartChannel String
Current dart platform channel
no setter
dartExecutable String?
Get dart vm either from executable or using the which command
no setter
dartVersion → Version
Current dart platform version
no setter
isFlutterSupported bool
true if flutter is supported
no setter
isFlutterSupportedSync bool
true if flutter is supported
no setter
platformEnvironment Map<String, String>
Environment without debug VM_OPTIONS and without any user overrides
getter/setter pair
sharedStdIn → SharedStdIn
A shared singleton instance of dart:io's stdin stream.
final
shellEnvironment Map<String, String>
Cached shell environment with user config Same as userEnvironment
getter/setter pair
userAppDataPath String
Returns the user data path
no setter
userEnvironment Map<String, String>
Get the user environment
no setter
userHomePath String
Return the user home path.
no setter
userPaths List<String>
Get the list of user paths used to resolve binaries location.
no setter

Functions

argumentsToString(List<String> arguments) String
Convert multiple arguments to string than can be used in a terminal
argumentToString(String argument) String
Helper to run a process and connect the input/output for verbosity
executableArgumentsToString(String executable, List<String>? arguments) String
Convenient way to display a command
getFlutterBinChannel() Future<String?>
Get flutter channel. (dev, beta, master, stable)
getFlutterBinVersion() Future<Version?>
Get flutter version.
processCmdToDebugString(ProcessCmd cmd) String
Process command debug string
processResultToDebugString(ProcessResult result) String
Process result debug string
prompt(String? text, {Stream<List<int>>? stdin}) Future<String>
Get text
promptConfirm(String? text, {Stream<List<int>>? stdin}) Future<bool>
Confirm action
promptTerminate() Future
Terminate a prompt session.
run(String script, {bool throwOnError = true, String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, Stream<List<int>>? stdin, StreamSink<List<int>>? stdout, StreamSink<List<int>>? stderr, bool verbose = true, bool? commandVerbose, bool? commentVerbose, ShellOptions? options, ShellOnProcessCallback? onProcess}) Future<List<ProcessResult>>
Run one or multiple plain text command(s).
runExecutableArguments(String executable, List<String> arguments, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding, Stream<List<int>>? stdin, StreamSink<List<int>>? stdout, StreamSink<List<int>>? stderr, bool? verbose, bool? commandVerbose, bool? noStdoutResult, bool? noStderrResult, ShellOnProcessCallback? onProcess}) Future<ProcessResult>
if commandVerbose or verbose is true, display the command. if verbose is true, stream stdout & stdin
runExecutableArgumentsSync(String executable, List<String> arguments, {String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding? stdoutEncoding = systemEncoding, Encoding? stderrEncoding = systemEncoding, StreamSink<List<int>>? stdout, StreamSink<List<int>>? stderr, bool? verbose, bool? commandVerbose}) ProcessResult
if commandVerbose or verbose is true, display the command. if verbose is true, stream stdout & stdin
runSync(String script, {bool throwOnError = true, String? workingDirectory, Map<String, String>? environment, bool includeParentEnvironment = true, bool? runInShell, Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, StreamSink<List<int>>? stdout, StreamSink<List<int>>? stderr, bool verbose = true, bool? commandVerbose, bool? commentVerbose, ShellOptions? options}) List<ProcessResult>
Run one or multiple plain text command(s).
shellArgument(String argument) String
Use to safely enclose an argument if needed
shellArguments(List<String> arguments) String
Convert multiple arguments to string than can be used in a terminal
shellExecutableArguments(String executable, List<String> arguments) String
Convert executable + arguments to a single script line
shellStreamLines(Stream<List<int>> stream, {Encoding? encoding}) Stream<String>
Basic line streaming. Assuming system encoding
stringToArguments(String command) List<String>
Convert a string command to arguments.
userLoadEnv({Map<String, String>? vars, List<String>? paths, Map<String, String>? aliases}) → void
Only specify the vars to override and the paths to add
userLoadEnvFile(String path) → void
Update userPaths and userEnvironment
which(String command, {Map<String, String>? environment, bool includeParentEnvironment = true}) Future<String?>
Find the command according to the paths or env variables (PATH)
whichSync(String command, {Map<String, String>? environment, bool includeParentEnvironment = true}) String?
Find the command according to the paths or env variables (PATH)

Typedefs

ShellOnProcessCallback = void Function(Process process)
Shell on process callback

Exceptions / Errors

ShellException
Exception thrown in exitCode != 0 and throwOnError is true