MainContext

public final class MainContext : Context, CommandRunning

Undocumented

  • The default character encoding used throughout SwiftShell. Only affects stdin, stdout and stderror if they have not been used yet.

    Declaration

    Swift

    public var encoding: String.Encoding
  • env

    Undocumented

    Declaration

    Swift

    public lazy var env: [String : String] { get set }
  • Undocumented

    Declaration

    Swift

    public lazy var stdin: ReadableStream { get set }
  • Undocumented

    Declaration

    Swift

    public lazy var stdout: WritableStream { get set }
  • Undocumented

    Declaration

    Swift

    public lazy var stderror: WritableStream { get set }
  • The current working directory.

    Must be used instead of run("cd", "...") because all the run commands are executed in separate processes and changing the directory there will not affect the rest of the Swift script.

    This directory is also used as the base for relative URLs.

    Declaration

    Swift

    public var currentdirectory: String { get set }
  • The tempdirectory is unique each time a script is run and is created the first time it is used. It lies in the user’s temporary directory and will be automatically deleted at some point.

    Declaration

    Swift

    public private(set) lazy var tempdirectory: String { get set }
  • The arguments this executable was launched with. Use main.path to get the path.

    Declaration

    Swift

    public private(set) lazy var arguments: [String] { get set }
  • The path to the currently running executable. Will be empty in playgrounds.

    Declaration

    Swift

    public private(set) lazy var path: String { get set }