utils library

Classes

Definition
A typical script definition.
Info
Package information which includes package name & version with both being String.
Pubspec
A singleton class that reads and caches the content of pubspec.yaml in current directory and provides utilities for .
Reference
A helper class to represent a reference to a script.
ScriptsRegistry
A class that holds scripts and provides utilities to work with them.

Constants

aliasesDefinitionKey → const String
Key used to define aliases for a script.
defaultDefinitionKey → const String
Key used to define a default script for a nested command group.
descriptionDefinitionKey → const String
Key used to define script description.
executionDefinitionKey → const String
Key used to select how a list of scripts is executed.
linuxDefinitionKey → const String
Platform-specific script keys.
macosDefinitionKey → const String
pubspecFileName → const String
referenceNestingDelimiter → const String
referencePrefix → const String
scriptsDefinitionKey → const String
Key used to define scripts.
scriptsKey → const String
variablesDefinitionKey → const String
Key used to define reusable variables for script interpolation.
windowsDefinitionKey → const String
workdirDefinitionKey → const String
Key used to set the working directory for a script.

Properties

currentPlatformKey String?
Returns the metadata key for the current OS, or null on unsupported platforms.
no setter

Functions

applyPositionalArgs(String script, List<String> args) MapEntry<String, List<String>>
Replaces $1, $2, etc. in script with positional args from args.
assertShellInert(String value, String describe) → void
Throws a FormatException if value carries a shell-active character.
collectVariables(JsonMap map) Map<String, String>
Collects all variable definitions from map by scanning for (variables) sections at every nesting level. Later definitions override earlier ones.
readYamlMap(String filePath) Future<Map>
Reads and returns a yaml file if exists and if the content is a map.
rejectRest(ArgResults argResults, String usage) → void
Throws a UsageException when argResults carries positional arguments a command takes no meaning from.
runnableScripts(Map map) → dynamic
Returns the value that makes map directly runnable on the current platform, or null if it only holds nested command groups and metadata.
shellChangeDirectory(String workdir) String
Builds a shell command that changes to workdir before continuing.
shellQuote(String arg) String
Quotes arg so the shell passes it through as a single argument.
shellSplit(String input) List<String>
Splits a shell command tail into the words the shell would pass as arguments, so --message "hello world" becomes two words rather than three.
substituteVariables(String script, Map<String, String> variables) String
Replaces ${VAR} tokens in script using variables first, then Platform.environment as fallback. Unknown variables are left unchanged.

Typedefs

JsonMap = Map<String, dynamic>
Json serializable map.