sidekick_core library

The core library for Sidekick CLIs

Classes

Ansi
Helper class to assist in printing text to the console with a color.
AnsiColor
Helper class to assist in printing text to the console with a color.
ArgParser
A class for taking a list of raw command line arguments and parsing out options and flags from them.
ArgResults
The results of parsing a series of command line arguments using ArgParser.parse.
Ask
Class for ask and related code.
AskValidator
Base class for all AskValidators. You can add your own by extending this class.
AskValidatorIPAddress
Validates that input is a IP address By default both v4 and v6 addresses are valid Pass a version to limit the input to one or the other. If passed version must be ipv4 or ipv6.
BashCommand
A Command that wraps a bash script
BytesBuilder
Builds a list of bytes, allowing bytes and lists of bytes to be added at the end.
CharacterRange
A range of characters of a Characters.
Characters
The characters of a string.
Column
Defined a column to sort by for the FileSort class.
Command<T>
A single command.
CommandRunner<T>
A class for invoking Commands based on raw command-line arguments.
ComparableRange<T extends Comparable<T>>
Represents a range of Comparable values such as String or DateTime
CompressionOptions
Options controlling compression in a WebSocket.
Confirm
ConnectionTask<S>
A cancelable connection attempt.
ContentType
A MIME/IANA media type used as the value of the HttpHeaders.contentTypeHeader header.
Context
An instantiable class for manipulating paths. Unlike the top-level functions, this lets you explicitly select what platform the paths will use.
Representation of a cookie. For cookies received by the server as Cookie header values only name and value properties will be set. When building a cookie for the 'set-cookie' header in the server and when receiving cookies in the client as 'set-cookie' headers all fields can be used.
DartAnalyzeCommand
dart analyze on the whole project
DartCommand
Makes the dart command available as subcommand
DartPackage
DartProject
DartScript
Used to manage a DCli script.
DartSdk
The DartSdk provides access to a number of the dart sdk tools as well as details on the active sdk instance.
Datagram
A data packet received by a RawDatagramSocket.
DCliPaths
platform specific names of the dcli commands.
Dependency
Defines a pubspec.yaml dependency.
DepsCommand
Downloads dependencies of all Flutter/Dart packages in the repository
Digest
A message digest as computed by a Hash or HMAC function.
Directory
A reference to a directory (or folder) on the file system.
DoubleRange
Env
Sets gets an environment variable for the current process.
FetchData
Used with the fetch function to send data for the likes of a POST command.
FetchProgress
Passed to the progress method to indicate the current progress of a download.
FetchUrl
Used to describe a url that is being downloaded including the location where it is going to be stored.
File
A reference to a file on the file system.
FileLock
Type of lock when requesting a lock on a file.
FileMode
The modes in which a File can be opened.
FileSort
FileSort provides the ability to sort files based on their columns.
FileStat
The result of calling the POSIX stat() function on a file system object.
FileSync
Provides a set of methods to read/write a file synchronisly.
FileSystemCreateEvent
File system event for newly created file system objects.
FileSystemDeleteEvent
File system event for deletion of file system objects.
FileSystemEntity
The common superclass of File, Directory, and Link.
FileSystemEntityType
The type of an entity on the file system, such as a file, directory, or link.
FileSystemEvent
Base event class emitted by FileSystemEntity.watch.
FileSystemModifyEvent
File system event for modifications of file system objects.
FileSystemMoveEvent
File system event for moving of file system objects.
Find
Implementation for the _find function.
FindItem
Holds details of a file system entity returned by the find function.
FlutterCommand
Makes the flutter command available as subcommand
Format
provides a random collection of formatters EXPERIMENTAL
FormatCommand
Formats the Code for all Flutter/Dart packages in the repository
ForwardCommand
A Command which accepts all arguments and forwards everything to another cli app
GZipCodec
The GZipCodec encodes raw bytes to GZip compressed bytes and decodes GZip compressed bytes to raw bytes.
HeaderValue
Representation of a header value in the form:
HttpClient
An HTTP client for communicating with an HTTP server.
HttpClientBasicCredentials
Represents credentials for basic authentication.
HttpClientCredentials
HttpClientDigestCredentials
Represents credentials for digest authentication. Digest authentication is only supported for servers using the MD5 algorithm and quality of protection (qop) of either "none" or "auth".
HttpClientRequest
HTTP request for a client connection.
HttpClientResponse
HTTP response for a client connection.
HttpConnectionInfo
Information about an HttpRequest, HttpResponse, HttpClientRequest, or HttpClientResponse connection.
HttpConnectionsInfo
Summary statistics about an HttpServers current socket connections.
HttpDate
Utility functions for working with dates with HTTP specific date formats.
HttpHeaders
Headers for HTTP requests and responses.
HttpOverrides
This class facilitates overriding HttpClient with a mock implementation. It should be extended by another class in client code with overrides that construct a mock implementation. The implementation in this base class defaults to the actual HttpClient implementation. For example:
HttpRequest
A server-side object that contains the content of and information about an HTTP request.
HttpResponse
An HTTP response, which returns the headers and data from the server to the client in response to an HTTP request.
HttpServer
A server that delivers content, such as web pages, using the HTTP protocol.
HttpSession
The HttpRequest.session of an HttpRequest.
HttpStatus
HTTP status codes. Exported in dart:io and dart:html.
InstallGlobalCommand
InternetAddress
An internet address or a Unix domain address.
InternetAddressType
The type, or address family, of an InternetAddress.
IntProgression
IntRange
A iterable range between two ints which is iterable with a specific step size
IOOverrides
Facilities for overriding various APIs of dart:io with mock implementations.
IOSink
A combined byte and text output.
References to filesystem links.
NamedLock
A NamedLock can be used to control access to a resource across processes and isolates.
NetworkInterface
A NetworkInterface represents an active network interface on the current system. It contains a list of InternetAddresses that are bound to the interface.
Option
A command-line option.
OptionType
What kinds of values an option accepts.
PackedResource
Base class used by all PackedResources.
Pair<A, B>
Represents a generic pair of two values.
PathMap<V>
A map whose keys are paths, compared using p.equals and p.hash.
PathSet
A set containing paths, compared using p.equals and p.hash.
Pipe
An anonymous pipe that can be used to send data in a single direction i.e. data written to write can be read using read.
Platform
Information about the environment in which the current program is running.
PluginsCommand
Plugins are extensions for sidekick CLIs that can be installed from pub.dev
Process
The means to execute a program.
ProcessDetails
Represents a running Process. As processes are transitory by the time you access these details the process may no longer be running.
ProcessHelper
EXPERIMENTAL
ProcessInfo
Methods for retrieving information about the current process.
ProcessResult
The result of running a non-interactive process started with Process.run or Process.runSync.
ProcessSignal
On Posix systems, ProcessSignal is used to send a specific signal to a child process, see Process.kill.
ProcessStartMode
Modes for running a new process.
Progress
central class that provides progress information about a running process.
PubCache
Used to locate and manipulate the dart pub cache
PubSpec
Used to read a pubspec.yaml file
RandomAccessFile
Random access to the data in a file.
Range<T extends Comparable>
Represents a range of values (for example, numbers or characters) with a fixed start value and a fixed endInclusive value.
RawDatagramSocket
An unbuffered interface to a UDP socket.
RawSecureServerSocket
A server socket providing a stream of low-level RawSecureSockets.
RawSecureSocket
RawSecureSocket provides a secure (SSL or TLS) network connection.
RawServerSocket
A listening socket.
RawSocket
A TCP connection.
RawSocketEvent
Events for the RawDatagramSocket, RawSecureSocket, and RawSocket.
RawSocketOption
The RawSocketOption is used as a parameter to Socket.setRawOption and RawSocket.setRawOption to customize the behaviour of the underlying socket.
RawSynchronousSocket
A low-level class for communicating synchronously over a TCP socket.
RawZLibFilter
The RawZLibFilter class provides a low-level interface to zlib.
ReadPipe
The "read" end of an Pipe created by Pipe.create.
RecompileCommand
Recompiles the sidekick cli
RedirectInfo
Redirect information.
Remote
Provides remote access methods for posix based systems.
Repository
The Git repository of the project
ResourceHandle
A wrapper around OS resource handle so it can be passed via Socket as part of SocketMessage.
SameSite
Cookie cross-site availability configuration.
SecureServerSocket
A server socket, providing a stream of high-level Sockets.
SecureSocket
A TCP socket using TLS and SSL.
SecurityContext
The object containing the certificates to trust when making a secure client connection, and the certificate chain and private key to serve from a secure server.
ServerSocket
A listening socket.
Settings
Holds all of the global settings for DCli including dcli paths and any global flags passed on the command line to DCli.
Shell
an abstract class which allows each shell (bash, zsh) to provide specific implementation of features required by DCli.
SidekickCommand
Sidekick CLI tools directly shipped from the sidekick_core package
SidekickCommandRunner<T>
A CommandRunner that makes lookups in SidekickContext faster
SidekickContext
Global information about the sidekick cli that is being executed
SidekickDartRuntime
The bundled Dart runtime of a sidekick CLI
SidekickPackage
The package that contains the generated sidekick cli code
SidekickTemplate
SidekickTemplateProperties
Socket
A TCP connection between two sockets.
SocketControlMessage
Control message part of the SocketMessage received by a call to RawSocket.readMessage.
SocketDirection
The SocketDirection is used as a parameter to Socket.close and RawSocket.close to close a socket in the specified direction(s).
SocketMessage
A socket message received by a RawDatagramSocket.
SocketOption
An option for a socket which is configured using Socket.setOption.
SortedList<E>
StackList<T>
A classic Stack of items with a push and pop method.
Stdin
The standard input stream of the process.
StdioType
The type of object a standard IO stream can be attached to.
Stdout
An IOSink connected to either the standard out or error of the process.
Style
An enum type describing a "flavor" of path.
SystemEncoding
The system encoding is the current code page on Windows and UTF-8 on Linux and Mac.
TemplateFlag
Allows a user to select which template to use when creating a project.
TemplateListFlag
Prints a list of the templates and exists
Terminal
Provides access to the Ansi Terminal.
UnknownShell
Used by dcli to interacte with the shell environment when we are unable to detect what shell is active. This may simply be the parent process of the dart app so not a shell at all.
Version
A parsed semantic version number.
WebSocket
A two-way HTTP communication object for client or server applications.
WebSocketStatus
WebSocket status codes used when closing a WebSocket connection.
WebSocketTransformer
The WebSocketTransformer provides the ability to upgrade a HttpRequest to a WebSocket connection. It supports both upgrading a single HttpRequest and upgrading a stream of HttpRequests.
WritePipe
The "write" end of an Pipe created by Pipe.create.
X509Certificate
X509Certificate represents an SSL certificate, with accessors to get the fields of the certificate.
ZLibCodec
The ZLibCodec encodes raw bytes to ZLib compressed bytes and decodes ZLib compressed bytes to raw bytes.
ZLibDecoder
The ZLibDecoder is used by ZLibCodec and GZipCodec to decompress data.
ZLibEncoder
The ZLibEncoder encoder is used by ZLibCodec and GZipCodec to compress data.
ZLibOption
Exposes ZLib options for input parameters.

Enums

FetchMethod
Http Methods used when calling fetch
FetchStatus
Used by FetchProgress to indicate the progress of a download.
HttpClientResponseCompressionState
Enum that specifies the compression state of the byte stream of an HttpClientResponse.
Interval
Allows you to specify how the duration argument to sleep is interpreted.
SortDirection
Sets the sort direction.
TableAlignment
Used by Format.row to control the alignment of each column in the table.
TerminalClearMode
Modes available when clearing a screen or line.

Extensions

ComparableBetweenExtension on T
ComparableBiggerEqualsExtension on T
ComparableBiggerExtension on T
ComparableCoerceAtLeastExtension on T
ComparableCoerceAtMostExtension on T
ComparableCoerceInExtension on T
ComparableInRangeExtension on T
ComparableRangeX on T
ComparableSmallerEqualsExtension on T
ComparableSmallerExtension on T
Provides comparison operators for Comparable types.
CompararatorComposeExtensions on Comparator<T>
CompararatorReverseExtensions on Comparator<T>
DateTimeTimeExtension on DateTime
DeleteDirContents on Directory
DigestHelper on Digest
Extends the Digest class to provide hex encoder/decoder
DirectoryContainsExtension on Directory
DirectoryContainsSyncExtension on Directory
DirectoryCopyRecursivelyExtension on Directory
DirectoryDirectoryExtension on Directory
DirectoryExt on Directory
DirectoryFileExtension on Directory
DirectorySubDirExtension on Directory
DoubleRangeToExtension on double
Special variant for double which implements Comparable<num> and therefore doesn't work for the Comparable<T>.rangeTo(T) extension
DoubleToBytesExtension on T
DurationTimeExtension on Duration
FileAppendBytesExtension on File
FileAppendStringExtension on File
FileForEachBlockExtension on File
FileModifier on File
FileSystemEntityDirNameExtension on FileSystemEntity
FileSystemEntityExt on FileSystemEntity
FileSystemEntityExtensionExtension on FileSystemEntity
FileSystemEntityIsWithinExtension on FileSystemEntity
FileSystemEntityNameExtension on FileSystemEntity
FileSystemEntityNameWithoutExtensionExtension on FileSystemEntity
FileSystemEntityWithNameExtension on FileSystemEntity
Function1InvokeExtensions on Function1<A, R>
Function1PartialExtensions on Function1<A, R>
Function2CurryExtension on Function2<A, B, R>
Function2FlipExtension on Function2<A, B, R>
Function2InvokeExtension on Function2<A, B, R>
Function2Partial2Extension on Function2<A, B, R>
Function2PartialExtension on Function2<A, B, R>
Function2UncurryExtension on Function1<A, Function1<B, R>>
Function3CurryExtension on Function3<A, B, C, R>
Function3InvokeExtension on Function3<A, B, C, R>
Function3Partial2Extension on Function3<A, B, C, R>
Function3Partial3Extension on Function3<A, B, C, R>
Function3PartialExtension on Function3<A, B, C, R>
Function3UncurryExtension on Function1<A, Function1<B, Function1<C, R>>>
Function4CurryExtension on Function4<A, B, C, D, R>
Function4InvokeExtension on Function4<A, B, C, D, R>
Function4Partial2Extension on Function4<A, B, C, D, R>
Function4Partial3Extension on Function4<A, B, C, D, R>
Function4Partial4Extension on Function4<A, B, C, D, R>
Function4PartialExtension on Function4<A, B, C, D, R>
Function4UncurryExtension on Function1<A, Function1<B, Function1<C, Function1<D, R>>>>
InterableMin on Iterable<E>
IntRangeToExtension on int
The equivalent for double is DoubleRangeExtension
IntToBytesExtension on T
IntToCharExtension on T
IterableAll on Iterable<E>
IterableAppend on Iterable<E>
IterableAppendElement on Iterable<E>
IterableAssociate on Iterable<E>
IterableAssociateBy on Iterable<E>
IterableAssociateWith on Iterable<E>
IterableAsStream on Iterable<E>
IterableAverageBy on Iterable<E>
IterableCached on Iterable<E>
IterableChunked on Iterable<E>
IterableChunkWhile on Iterable<E>
IterableContainsAll on Iterable<E>
IterableContainsAny on Iterable<E>
IterableContentEquals on Iterable<E>
IterableCount on Iterable<E>
IterableCycle on Iterable<E>
IterableDistinct on Iterable<E>
IterableDistinctBy on Iterable<E>
IterableElementAtOrDefault on Iterable<E>
IterableElementAtOrElse on Iterable<E>
IterableElementAtOrNull on Iterable<E>
IterableExcept on Iterable<E>
IterableExceptElement on Iterable<E>
IterableFilter on Iterable<E>
IterableFilterIndexed on Iterable<E>
IterableFilterIndexedTo on Iterable<E>
IterableFilterNot on Iterable<E>
IterableFilterNotIndexed on Iterable<E>
IterableFilterNotNull on Iterable<E?>
IterableFilterNotTo on Iterable<E>
IterableFilterNotToIndexed on Iterable<E>
IterableFilterTo on Iterable<E>
IterableFirstOrDefault on Iterable<E>
IterableFirstOrNull on Iterable<E>
IterableFirstOrNullWhere on Iterable<E>
IterableFirstWhile on Iterable<E>
IterableFlatMap on Iterable<E>
IterableForEachIndexed on Iterable<E>
IterableFourthItem on Iterable<E>
IterableFutureX on Iterable<Future<E>>
IterableGroupBy on Iterable<E>
IterableIntersect on Iterable<E>
IterableIterableX on Iterable<Iterable<E>>
IterableJoinToString on Iterable<E>
IterableLastOrElse on Iterable<E>
IterableLastOrNull on Iterable<E>
IterableLastOrNullWhere on Iterable<E>
IterableLastWhile on Iterable<E>
IterableMapIndexed on Iterable<E>
IterableMapIndexedNotNull on Iterable<E>
IterableMapNotNull on Iterable<E>
IterableMax on Iterable<E>
IterableMaxBy on Iterable<E>
IterableMaxWith on Iterable<E>
IterableMinBy on Iterable<E>
IterableMinus on Iterable<E>
IterableMinWith on Iterable<E>
IterableNone on Iterable<E>
IterableNumAverageExtension on Iterable<T>
IterableNumMedianExtension on Iterable<T>
IterableNumSumExtension on Iterable<T>
Extensions for iterables
IterableOnEach on Iterable<E>
IterablePartition on Iterable<E>
IterablePlus on Iterable<E>
IterablePrepend on Iterable<E>
IterablePrependElement on Iterable<E>
IterableReversed on Iterable<E>
IterableSecondItem on Iterable<E>
IterableShuffled on Iterable<E>
IterableSlice on Iterable<E>
IterableSorted on Iterable<E>
IterableSortedBy on Iterable<E>
IterableSortedByDescending on Iterable<E>
IterableSortedDescending on Iterable<E>
IterableSortedWith on Iterable<E>
IterableSplitWhen on Iterable<E>
IterableStartsWithExtension on Iterable<E>
IterableSumBy on Iterable<E>
IterableTakeFirst on Iterable<E>
IterableTakeLast on Iterable<E>
IterableThirdItem on Iterable<E>
IterableToHashSet on Iterable<E>
IterableToIterable on Iterable<E>
IterableToUnmodifiable on Iterable<E>
IterableUnion on Iterable<E>
IterableWhereIndexed on Iterable<E>
IterableWhereIndexedTo on Iterable<E>
IterableWhereNot on Iterable<E>
IterableWhereNotIndexed on Iterable<E>
IterableWhereNotNull on Iterable<E?>
IterableWhereNotTo on Iterable<E>
IterableWhereNotToIndexed on Iterable<E>
IterableWhereTo on Iterable<E>
IterableWindowed on Iterable<E>
IterableZip on Iterable<E>
ListBinarySearchExtension on List<E>
ListDropExtension on List<E>
ListDropLastExtension on List<E>
ListDropLastWhileExtension on List<E>
ListDropWhileExtension on List<E>
ListElementAtOrNull on List<E>
ListExtension on List<E>
ListFlattenExtension on List<List<E>>
ListIndicesExtension on List<E>
ListInsertionSortExtension on List<E>
ListLastIndexExtension on List<E>
ListLowerBoundExtension on List<E>
ListMergeSortExtension on List<E>
ListSwapExtension on List<E>
MakeExecutable on FileSystemEntity
MapAll on Map<K, V>
MapAny on Map<K, V>
MapCount on Map<K, V>
MapEntries on Map<K, V>
MapFilter on Map<K, V>
MapFilterKeys on Map<K, V>
MapFilterNot on Map<K, V>
MapFilterValues on Map<K, V>
MapGetOrElse on Map<K, V>
MapMapKeys on Map<K, V>
MapMapValues on Map<K, V>
MapMaxBy on Map<K, V>
MapMaxWith on Map<K, V>
MapMinBy on Map<K, V>
MapMinWith on Map<K, V>
MapNone on Map<K, V>
MapOrEmpty on Map<K, V>?
MapToList on Map<K, V>
MapToMap on Map<K, V>
NullableStringIsNotNullOrBlankExtension on String?
NullableStringIsNotNullOrEmptyExtension on String?
NullableStringIsNullOrBlankExtension on String?
NullableStringIsNullOrEmptyExtension on String?
NullableStringOrEmptyExtension on String?
NumArithmeticX on T
NumBetweenExtension on T
NumCoerceAtLeastExtension on T
NumCoerceAtMostExtension on T
NumCoerceInExtension on T
NumCoerceInRangeExtension on T
NumTimeExtension on T
Ordinals on T
PairDeconstruction on Pair<T, T>
PlatformEx on Platform
Extensions for the Platform class
StringAsProcess on String
A set of String extensions that lets you execute the contents of a string as a command line application.
StringBufferWriteSpaceExtension on StringBuffer
StringCapitalizeExtension on String
StringCharacters on String
StringDecapitalizeExtension on String
StringIsAsciiExtension on String
StringIsBlankExtension on String
StringIsCapitalizedExtension on String
StringIsDecapitalizedExtension on String
StringIsDoubleExtension on String
StringIsIntExtension on String
StringIsLatin1Extension on String
StringIsLowerCaseExtension on String
StringIsNotBlankExtension on String
StringIsUpperCaseExtension on String
StringMatchesExtension on String
StringMd5Extension on String
StringRemovePrefixExtension on String
StringRemoveSuffixExtension on String
StringRemoveSurroundingExtension on String
StringReversedExtension on String
StringSliceExtension on String
StringToDoubleExtension on String
StringToDoubleOrNullExtension on String
StringToIntExtension on String
StringToIntOrNullExtension on String
StringToUtf16Extension on String
StringToUtf8Extension on String
StringUrlCodingExtension on String

Constants

gzip → const GZipCodec
An instance of the default implementation of the GZipCodec.
systemEncoding → const SystemEncoding
The current system encoding.
zlib → const ZLibCodec
An instance of the default implementation of the ZLibCodec.

Properties

cliName String
Name of the cli program
no setter
cliNameOrNull String?
Name of the cli program (if running a generated sidekick CLI) or null (if running the global sidekick CLI)
no setter
context Context
The system path context.
final
current String
Gets the path to the current working directory.
no setter
dartSdk Directory?
Returns the path to the Dart SDK sidekick should use for the dart command
no setter
entryWorkingDirectory Directory
The working directory (cwd) from which the cli run method was started
no setter
env Env
Provides access to shell environment variables.
no setter
envs Map<String, String>
Returns a map of all the environment variables inherited from the parent as well as any changes made by calls to env[]=.
no setter
exitCode int
Get the global exit code for the Dart VM.
getter/setter pair
fileList List<String>
returns the list of files and directories in the current directory.
no setter
flutterSdk Directory?
Returns the path to he Flutter SDK sidekick should use for the flutter command
no setter
HOME String
returns the path to the OS specific HOME directory
no setter
mainProject DartPackage?
The main package which should be executed by default
no setter
PATH List<String>
Returns the list of directory paths that are contained in the OS's PATH environment variable. They are returned in the same order that they appear within the PATH environment variable (as order is important.)
no setter
pid int
Returns the PID of the current process.
no setter
posix Context
A default context for manipulating POSIX paths.
final
pwd String
Returns the current working directory.
no setter
repository Repository
The root of the repository which contains all projects
no setter
rootPath String
Returns the root path of your file system.
no setter
separator String
Gets the path separator for the current platform. This is \ on Windows and / on other platforms (including the browser).
no setter
sidekickDartRuntime SidekickDartRuntime
default Dart runtime which is currently used to execute this sidekick CLI
no setter
sidekickDartVersion → SdkVersion
Version and channel of sidekickDartRuntime
final
stderr Stdout
The standard output stream of errors written by this program.
no setter
stdin Stdin
The standard input stream of data read by this program.
no setter
stdout Stdout
The standard output stream of data written by this program.
no setter
style Style
Returns the Style of the current context.
no setter
url Context
A default context for manipulating URLs.
final
version Version
The version of package:sidekick_core
final
windows Context
A default context for manipulating Windows paths.
final

Functions

addFlutterSdkInitializer(FlutterInitializer initializer) Removable
Registers an initializer function that is called before executing the flutter command to prepare the SDK, such as downloading it.
addUnitTestOverrides(String pathToProject) → void
ask(String prompt, {bool toLower = false, bool hidden = false, bool required = true, String? defaultValue, CustomAskPrompt customPrompt = Ask.defaultPrompt, AskValidator validator = Ask.dontCare}) String
Reads a line of text from stdin with an optional prompt.
backupFile(String pathToFile, {bool ignoreMissing = false}) → void
Provide a very simple mechanism to backup a single file.
basename(String path) String
Gets the part of path after the last separator.
basenameWithoutExtension(String path) String
Gets the part of path after the last separator, and without any trailing file extension.
black(String text, {AnsiColor background = AnsiColor.white, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
blue(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
buildString(void builderAction(StringBuffer sb)) String
Builds new string by populating newly created StringBuffer using provided builderAction and then converting it to String.
calculateHash(String path) Digest
Calculates the sha256 hash of a file's content.
canonicalize(String path) String
Canonicalizes path.
capture<R>(Future<R> action(), {Progress? progress}) Future<Progress>
Run code in a zone which traps calls to print and printerr redirecting them to the passed progress. If no progress is passed then then both print and printerr output is surpressed.
cat(String path, {LineAction stdout = print}) → void
Prints the contents of the file located at path to stdout.
confirm(String prompt, {bool? defaultValue, CustomConfirmPrompt customPrompt = Confirm.defaultPrompt}) bool
confirm is a specialized version of ask that returns true or false based on the value entered.
copy(String from, String to, {bool overwrite = false}) → void
Copies the file from to the path to.
copyTree(String from, String to, {bool overwrite = false, bool includeHidden = false, bool recursive = true, bool filter(String file) = _allowAll}) → void
Copies the contents of the from directory to the to path with an optional filter.
createDir(String path, {bool recursive = false}) String
Creates a directory as described by path. Path may be a single path segment (e.g. bin) or a full or partial tree (e.g. /usr/bin)
createTempDir() String
Creates a temporary directory under the system temp folder. The temporary directory name is formed from a uuid. It is your responsiblity to delete the directory once you have finsihed with it.
createTempFile({String? suffix}) String
Generates a temporary filename in the system temp directory that is guaranteed to be unique.
createTempFilename({String? suffix, String? pathToTempDir}) String
Generates a temporary filename in pathToTempDir or if inTempDir os not passed then in the system temp directory. The generated filename is is guaranteed to be globally unique.
cyan(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
dart(List<String> args, {Directory? workingDirectory, Progress? progress, bool nothrow = false, String throwOnError()?}) int
Executes the dart cli associated with the project via flutterw https://github.com/passsy/flutter_wrapper
delete(String path, {bool ask = false}) → void
Deletes the file at path.
deleteDir(String path, {bool recursive = true}) → void
Deletes the directory located at path.
Deletes the symlink at linkPath
devNull(String? line) → void
devNull is a convenience function which you can use if you want to ignore the output of a LineAction. Its typical useage is a forEach where you don't want to see any stdout but you still want to see errors printed to stderr.
dirname(String path) String
Gets the part of path before the last separator.
echo(String text, {bool newline = false}) → void
Writes text to stdout including a newline.
equals(String path1, String path2) bool
Returns true if path1 points to the same location as path2, and false otherwise.
error(String message, {int? errorCode}) → Never
Exits the CLI immediately with a messages
exists(String path, {bool followLinks = true}) bool
Returns true if the given path exists. It may be a file, directory or link.
exit(int code) → Never
Exit the Dart VM process immediately with the given exit code.
extension(String path, [int level = 1]) String
Gets the file extension of path: the portion of basename from the last . to the end (including the . itself).
fetch({required String url, required String saveToPath, FetchMethod method = FetchMethod.get, Map<String, String>? headers, OnFetchProgress fetchProgress = _devNull, FetchData? data}) → void
Fetches the given resource at the passed url.
fetchMultiple({required List<FetchUrl> urls}) → void
Fetches the list of of resources indicated by urls;
fileLength(String pathToFile) int
Returns the length of the file at pathToFile in bytes.
find(String pattern, {bool caseSensitive = false, bool recursive = true, bool includeHidden = false, String workingDirectory = '.', Progress? progress, List<FileSystemEntityType> types = const [Find.file]}) → FindProgress
Returns the list of files in the current and child directories that match the passed glob pattern.
findAllPackages(Directory directory) List<DartPackage>
Returns the list of all packages in the repository
findRepository() Repository
Finds the root of the repo
flutter(List<String> args, {Directory? workingDirectory, Progress? progress, bool nothrow = false, String throwOnError()?}) int
Executes Flutter command from Flutter SDK set in flutterSdk
fromUri(Object? uri) String
Returns the path represented by uri, which may be a String or a Uri.
green(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
grey(String text, {double level = 0.5, AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
hash(String path) int
Returns a hash code for path such that, if equals returns true for two paths, their hash codes are the same.
Prepares to read count lines from the file at path.
initializeSidekick({String? name, String? description, String? mainProjectPath, String? flutterSdkPath, String? dartSdkPath}) SidekickCommandRunner
Initializes sidekick, call this at the very start of your CLI program
isAbsolute(String path) bool
Returns true if path is an absolute path and false if it is a relative path.
isDirectory(String path) bool
Returns true if the given path is a directory.
isEmpty(String pathToDirectory) bool
Returns true if the passed pathToDirectory is an empty directory. For large directories this operation can be expensive.
isExecutable(String path) bool
checks if the passed path (a file or directory) is executable by the user that owns this process
isFile(String path) bool
Returns true if the given path points to a file. If path is a link the link will be followed and we report on the resolved path.
Returns true if the given path is a symlink
isOnPATH(String path) bool
Tests if the given path is contained in the OS's PATH environment variable. An canonicalized match of path is made against each path on the OS's path.
isProgramInstalled(String name) bool
Returns true when the cli program named name is available via PATH
isReadable(String path) bool
checks if the passed path (a file or directory) is readable by the user that owns this process
isRelative(String path) bool
Returns true if path is a relative path and false if it is absolute. On POSIX systems, absolute paths start with a / (forward slash). On Windows, an absolute path starts with \\, or a drive letter followed by :/ or :\.
isRootRelative(String path) bool
Returns true if path is a root-relative path and false if it's not.
isValidPubPackageName(String name) bool
Returns true when the name is a valid pub package name according to https://dart.dev/tools/pub/pubspec#name
isWithin(String parent, String child) bool
Returns true if child is a path beneath parent, and false otherwise.
isWritable(String path) bool
checks if the passed path (a file or directory) is writable by the user that owns this process
join(String part1, [String? part2, String? part3, String? part4, String? part5, String? part6, String? part7, String? part8, String? part9, String? part10, String? part11, String? part12, String? part13, String? part14, String? part15, String? part16]) String
Joins the given path parts into a single path using the current platform's separator. Example:
joinAll(Iterable<String> parts) String
Joins the given path parts into a single path using the current platform's separator. Example:
lastModified(String path) DateTime
Returns the datetime the path was last modified
magenta(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
makeValidPubPackageName(String name) String
Converts any string to a valid pub package name to only use basic Latin letters and Arabic digits: a-z0-9_.
Displays a menu with each of the provided options, prompts the user to select an option and returns the selected option.
move(String from, String to, {bool overwrite = false}) → void
Moves the file from to the location to.
moveDir(String from, String to) → void
Moves or renames the from directory to the to the to path.
moveTree(String from, String to, {bool overwrite = false, bool includeHidden = false, bool filter(String file) = _allowAll}) → void
Recursively moves the contents of the from directory to the to the to path with an optional filter.
normalize(String path) String
Normalizes path, simplifying it by handling .., and ., and removing redundant path separators whenever possible.
orange(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
prettyUri(Object? uri) String
Returns a terse, human-readable representation of uri.
printerr(String? line) → void
printerr provides the equivalent functionality to the standard Dart print function but instead writes the output to stderr rather than stdout.
privatePath(String part1, [String? part2, String? part3, String? part4, String? part5, String? part6, String? part7]) String
Removes the users home directory from a path replacing it with ~
read(String path, {String delim = '\n'}) Progress
Reads lines from the file at path.
readStdin() Progress
Read lines from stdin
red(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
relative(String path, {String? from}) String
Attempts to convert path to an equivalent relative path from the current directory.
replace(String path, Pattern existing, String replacement, {bool all = false}) int
Does an insitu replacement on the file located at path.
Resolves the a symbolic link pathToLink to the ultimate target path.
restoreFile(String pathToFile, {bool ignoreMissing = false}) → void
Designed to work with backupFile to restore a file from backup. The existing file is deleted and restored from the .bak/
rootPrefix(String path) String
Returns the root of path, if it's absolute, or the empty string if it's relative.
setExtension(String path, String extension) String
Returns path with the trailing extension set to extension.
setLastModifed(String path, DateTime lastModified) → void
Sets the last modified datetime on the given the path.
showEditor(String path) → void
Launches the systems default cli editor on Linux and MacOS using the EDITOR environment variable.
sleep(int duration, {Interval interval = Interval.seconds}) → void
sleeps for the provided duration of the given interval.
split(String path) List<String>
Splits path into its components using the current platform's separator.
stat(String path) FileStat
Returns a FileStat instance describing the file or directory located by path.
stdioType(dynamic object) StdioType
Whether a stream is attached to a file, pipe, terminal, or something else.
Creates a link at linkPath which points to an existing file or directory at existingPath
systemDart(List<String> args, {Directory? workingDirectory, Progress? progress, bool nothrow = false, String throwOnError()?}) int
Executes the system dart cli which is globally available on PATH
systemDartExecutable() String?
systemDartSdk() Directory?
Returns the Dart SDK of the dart executable on PATH
systemDartSdkPath() String?
Returns the path to Dart SDK of the dart executable on PATH
systemFlutterSdk() Directory?
Returns the Flutter SDK of the flutter executable on PATH
systemFlutterSdkPath() String?
Returns the path to Flutter SDK of the flutter executable on PATH
tail(String path, int lines) → TailProgress
Returns count lines from the end of the file at path.
tempExecutableScriptFile(String content, {Directory? tempDir}) File
Writes content as executable *.sh file in a temp directory
touch(String path, {bool create = false}) String
Updates the last modified time stamp of a file.
toUri(String path) Uri
Returns the URI that represents path.
translateAbsolutePath(String absolutePath, {String? workingDirectory, Context? context}) String
Windows, an absolute path starts with \\, or a drive letter followed by :/ or :\. This method will strip the prefix so the path start with a \ or / and the prepend the drive letter so that it becomes a valid path. If the absolutePath doesn't contain a drive letter then we take the drive letter from the workingDirectory. If this is a linux absolute path it is returned unchanged.
truepath(String part1, [String? part2, String? part3, String? part4, String? part5, String? part6, String? part7]) String
truepath creates an absolute and normalized path.
verbose(String callback()) → void
If Settings.isVerbose is true then this method will call callback to get a String which will be logged to the console or the log file set via the verbose command line option.
waitForEx<T>(Future<T> wrapped) → T
Changes a async call into a synchronous call.
which(String appname, {bool first = true, bool verbose = false, bool extensionSearch = true, Sink<String>? progress}) → Which
Searches the PATH for the location of the application give by appname.
white(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.
withEnvironment<R>(Future<R> callback(), {required Map<String, String> environment}) Future<R>
Creates a environment that is contained to the scope of the callback method.
withFileProtection<R>(List<String> protected, R action(), {String? workingDirectory}) → R
EXPERIMENTAL - use with caution and the api may change.
withOpenFile<R>(String pathToFile, R action(FileSync), {FileMode fileMode = FileMode.writeOnlyAppend}) → R
Opens a File and calls action passing in the open file. When action completes the file is closed. Use this method in preference to directly callling FileSync()
withoutExtension(String path) String
Removes a trailing extension from the last part of path.
withTempDir<R>(R action(String tempDir), {bool keep = false, String? pathToTempDir}) → R
Creates a temp directory and then calls action. Once action completes the temporary directory will be deleted.
withTempFile<R>(R action(String tempFile), {String? suffix, String? pathToTempDir, bool create = true, bool keep = false}) → R
Creates a temp file and then calls action.
writeAndRunShellScript(String scriptContent, {List<String> args = const [], Directory? workingDirectory, Progress? progress, bool terminal = false}) Progress
Executes a script by first writing it as file and then running it as shell script
yellow(String text, {AnsiColor background = AnsiColor.none, bool bold = true}) String
Wraps the passed text with the ANSI escape sequence for the color red. Use this to control the color of text when printing to the console.

Typedefs

BadCertificateCallback = bool Function(X509Certificate cr, String host, int port)
CancelableLineAction = bool Function(String line)
Typedef for cancellable LineActions.
CustomAskPrompt = String Function(String prompt, String? defaultValue, bool hidden)
CustomConfirmPrompt = String Function(String prompt, bool? defaultValue)
FlutterInitializer = FutureOr<void> Function(Directory sdkDir)
Called by flutter before executing the flutter executable
Function0<R> = R Function()
Function1<A, R> = R Function(A a)
Function2<A, B, R> = R Function(A a, B b)
Function3<A, B, C, R> = R Function(A a, B b, C c)
Function4<A, B, C, D, R> = R Function(A a, B b, C c, D d)
LineAction = void Function(String line)
Typedef for LineActions
OnFetchProgress = void Function(FetchProgress progress)
Typedef for the progress call back used by the fetch function.
Removable = void Function()
Can be called to remove a listener
RunPrivileged = void Function()
Typedef for the withPrivileges function.
Unmount = void Function()

Exceptions / Errors

ArgParserException
An exception thrown by ArgParser.
AskValidatorException
Thrown when an AskValidator detects an invalid input.
BackupFileException
Thrown by the backupFile function when the file to be backed up is missing.
BashCommandException
Exception thrown when a BashCommand fails containing all the information about the script and its error
CatException
Thrown if the cat function encouters an error.
CertificateException
An exception that happens in the handshake phase of establishing a secure network connection, when looking up or verifying a certificate.
CopyException
Throw when the copy function encounters an error.
CreateDirException
Thrown when the function createDir encounters an error
DartProjectException
Exception for issues with DartProjects.
DartSdkNotSetException
The Dart SDK path is not set in initializeSidekick (param dartSdk, neither is is the flutterSdk)
DCliException
Base class for all DCli exceptions.
DeleteDirException
Throw when deleteDir function encounters an error
DeleteException
Thrown when the delete function encounters an error
FetchException
Throw when an error occurs fetching a resource.
FileNotFoundException
Thrown when a file doesn't exist
FileSystemException
Exception thrown when a file operation fails.
FlutterSdkNotSetException
The Flutter SDK path is not set in initializeSidekick (param flutterSdk)
HandshakeException
An exception that happens in the handshake phase of establishing a secure network connection.
HttpException
InvalidProjectTemplateException
IOException
Base class for all IO related exceptions.
LockException
MoveDirException
Thrown when the moveDir function encouters an error.
MoveException
Thrown when the move function encouters an error.
MoveTreeException
Thrown when the moveTree function encouters an error.
NotAFileException
Thrown when a path is not a file.
OSError
An Exception holding information about an error from the operating system.
OutOfCommandRunnerScopeException
Called when properties of SidekickCommandRunner are accessed outside of the execution of a command
PathAccessException
Exception thrown when a file operation fails because the necessary access rights are not available.
PathException
An exception class that's thrown when a path operation is unable to be computed accurately.
PathExistsException
Exception thrown when a file operation fails because the target path already exists.
PathNotFoundException
Exception thrown when a file operation fails because a file or directory does not exist.
ProcessException
ReadException
Thrown when the read function encouters an error.
RedirectException
RestoreFileException
Thrown by the restoreFile function when the backup file is missing.
RunException
Thrown when any of the process related method such as .run and .start fail.
SdkNotFoundException
The Dart or Flutter SDK path is set in initializeSidekick, but the directory doesn't exist
ShellException
Thrown when an exception occurs in the Shell detection and support methods.
SignalException
SocketException
Exception thrown when a socket operation fails.
StdinException
Exception thrown by some operations of Stdin
StdoutException
Exception thrown by some operations of Stdout
TemplateNotFoundException
The requested DCli template does not exists.
TlsException
A secure networking exception caused by a failure in the TLS/SSL protocol.
UsageException
WebSocketException