Shell class Null safety

an abstract class which allows each shell (bash, zsh) to provide specific implementation of features required by DCli.

Implementers
Annotations

Constructors

Shell()

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
hasStartScript bool
True if this shell supports a start script or configuration file. e.g. a script that is run by the shell or a configuration file that is read when the shell starts.
read-only
installInstructions String
Returns instructions on how to install DCli.
read-only
isCompletionInstalled bool
read-only
isCompletionSupported bool
read-only
isPrivilegedPasswordRequired bool
Returns true if running a privileged action would cause a password to be requested. [...]
read-only
isPrivilegedProcess bool
Returns true if the process was launched as a priviliged process. [...]
read-only
isPrivilegedUser bool
Returns true if the current user this process is running as has esclated privileges. [...]
read-only
isSudo bool
A derived class should overload this method and return true if the script is running under sudo.
read-only
loggedInUser String?
Returns the username of the logged in user. [...]
read-only
name String
The name of the shell e.g. bash
read-only
pathToStartScript String?
Returns the path to the shell's start script or config file e.g /home//.bashrc
read-only
pid int?
The pid of the current shell
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
startScriptName String
Returns the name of the shell's startup script or configuration file e.g. .bashrc
read-only

Methods

addFileAssocation(String dcliPath) → void
Called during the install so that an OS that needs to create a file association between .dart and dcli can create that association. The implementor is responsible for not adding the association if it already exists.
addToPATH(String path) bool
Adds a path to the start script returns true if adding the path was successful
@Deprecated('Use appendToPATH')
appendToPATH(String path) bool
Appends path to the end of the PATH in a persistent manner. Note: this doesn't update current scripts path. Returns true if we successfully appended the path. In almost all shells you will need to restart the terminal in order for the path change to take affect.
checkInstallPreconditions() String?
Some OS/Shell combinations have some preconditions that must be met before dcli can be installed. [...]
install({bool installDart = false}) bool
Installs dart and dcli. Returns true if dart was installed. Returns false if dart was already installed.
installTabCompletion({bool quiet = true}) → void
If the shell supports tab completion then install it. If quiet is true then suppress any console output except for errors.
matchByName(String name) bool
Returns true if the shells name matches the passed name. The comparison is case insensitive.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
prependToPATH(String path) bool
Prepends path to the start of the PATH in a persistent manner. Note: this doesn't update current scripts path. Returns true if we successfully prepended the path. In almost all shells you will need to restart the terminal in order for the path change to take affect.
privilegesRequiredMessage(String appname) String
Returns a message informing the user that they need to run as a priviledged user to run an app.
releasePrivileges() → void
On Linux and MacOS systems makes the script run as a non-privileged user even when started with sudo. [...]
restorePrivileges() → void
If releasePrivileges has been called then this method will restore those privileges See [...]
toString() String
A string representation of this object. [...]
inherited
withPrivileges(RunPrivileged action, {bool allowUnprivileged = false}) → void
When a script is run under sudo on Linux and MacOS and you have previously called releasePrivileges then this method will run action with root privileges. [...]

Operators

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

Static Properties

current Shell
Returns the user shell that this script was launched from e.g. bash, powershell, .... If the shell can't be deteremined then the UnknownShell is returned.
read-only