Shell class abstract

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

Implementers
Annotations
  • @immutable

Constructors

Shell()

Properties

canModifyPath bool
Returns true if this shell supports modifying the shell's PATH
no setter
hashCode int
The hash code for this object.
no setterinherited
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.
no setter
installInstructions String
Returns instructions on how to install DCli.
no setter
isCompletionInstalled bool
no setter
isCompletionSupported bool
no setter
isPrivilegedPasswordRequired bool
Returns true if running a privileged action would cause a password to be requested.
no setter
isPrivilegedProcess bool
Returns true if the process was launched as a priviliged process.
no setter
isPrivilegedUser bool
Returns true if the current user this process is running as has esclated privileges.
no setter
isSudo bool
A derived class should overload this method and return true if the script is running under sudo.
no setter
loggedInUser String?
Returns the username of the logged in user.
no setter
name String
The name of the shell e.g. bash
no setter
pathToStartScript String?
Returns the path to the shell's start script or config file e.g /home/
no setter
pid int?
The pid of the current shell
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startScriptName String
Returns the name of the shell's startup script or configuration file e.g. .bashrc
no setter

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
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}) Future<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 nonexistent 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.
no setter