Package
ConsoleKit
Utilities for interacting with a terminal and the commandline in a Swift application.
Overview
ConsoleKit is an umbrella module, exporting ConsoleKitTerminal and ConsoleKitCommands. It has no separate functionality of its own.
Topics
Classes
class ActivityIndicatorAn instance of aActivityIndicatorTypethat can be started, failed, and succeeded.class ArgumentAn argument for a console commandclass FlagA supported option for a command.class OptionA supported option for a command.class TerminalGeneric console that uses a mixture of Swift standard library and Foundation code to fulfill protocol requirements.
Protocols
protocol ActivityBarAnActivityIndicatorTypethat renders an activity bar on a single line.protocol ActivityIndicatorTypeActivityIndicatorTypes are responsible for drawing / rendering the currentActivityIndicatorStateto theConsole.protocol AnyAsyncCommandA type-erasedCommand.protocol AnyCommandA type-erasedCommand.protocol AsyncCommandA command that can be run through aConsole.protocol AsyncCommandGroupA group of named commands that can be run through aConsole.protocol CommandA command that can be run through aConsole.protocol CommandGroupA group of named commands that can be run through aConsole.protocol CommandSignatureThe structure of the inputs that a command can takeprotocol ConsoleProtocol for powering styled Console I/O.protocol LoggerFragmentA fragment of a log message.protocol TimestampSourceA protocol to allow mocking the timestamp for tests
Structures
struct AndFragmentCombine the current fragment with another, which will be written after the current fragment finishes.struct AnySendableHashableASendableversion of the standard library’sAnyHashabletype.struct AsyncCommandsRepresents a top-level group of configured commands. This is usually created by callingresolve(for:)onAsyncCommands.struct CommandContextA type-erasedCommandContextstruct CommandInputRaw input for commands. Use this to parse options and arguments for the command context.struct CommandsRepresents a top-level group of configured commands. This is usually created by callingresolve(for:)onCommands.struct CompletionActionAn action to be used in the shell completion script(s) to provide special shell completion behaviors for anOption’s argument or a positionalArgument.struct ConsoleErrorstruct ConsoleFragmentLoggerOutputs logs to aConsolevia aLoggerFragmentpipeline.struct ConsoleStyleRepresentation of a style for outputting to a Console in different colors with differing attributes. A few suggested default styles are provided.struct ConsoleTextA collection ofConsoleTextFragments. Represents stylized text that can be outputted to aConsole.struct ConsoleTextFragmentA single piece ofConsoleText. Contains a rawStringand the desiredConsoleStyle.struct CustomActivityAn activity indicator with customizable frames and success and failure messages.struct FragmentOutputThe output of aLoggerFragment, including some intermediary state used for things like deduplicating separators.struct IfMaxLevelFragmentMake the current fragment conditional, only calling itsoutputmethod if the record’sloggerLevelismaxLevelor lowerstruct LabelFragmentWrites the label of the logger, and requests a separator for the next fragment.struct LevelFragmentWrites the level of the logged message, and requests a separator for the next fragment.struct LiteralFragmentWrites the given text to the output. This type does not request a separator for the next fragmentstruct LoadingBarLoading-style implementation ofActivityBar.struct LogRecordInformation about a specific log message, including information from the logger the message was logged to.struct LoggerSourceFragmentWrites the source of the logged message. By default the source is the name of the module the message was logged in.struct MergedAsyncCommandGroupstruct MessageFragmentWrites the logged message to the output, and requests a separator for the next fragment.struct MetadataFragmentWrites the combined metadata to the output, and requests a separator for the next fragment only if the metadata was not empty.struct ProgressBarProgress-style implementation ofActivityBar.struct SeparatorFragmentstruct SourceLocationFragmentWrites the file location of the logged message, including the line. This fragment requests a separator for the next fragment.struct SystemTimestampSourceThe defaultTimestampSource, which gets the time from the system.struct TimestampFragmentWrites a formatted timestamp based on the time obtained from theTimestampSource.
Functions
func defaultLoggerFragment() -> DefaultLoggerFragmentTypeALoggerFragmentwhich implements the default logger message format.func timestampDefaultLoggerFragment(timestampSource: some TimestampSource) -> some LoggerFragmentALoggerFragmentwhich implements the default logger message format with a timestamp at the front.
Operators
func + (ConsoleText, ConsoleText) -> ConsoleTextAppends aConsoleTextto anotherConsoleText.func += (inout ConsoleText, ConsoleText)Appends aConsoleTextto anotherConsoleTextin-place.
Type Aliases
typealias ConsoleLoggerOutputs logs to aConsoleusing thedefaultLoggerFragment().typealias DefaultLoggerFragmentTypeThe complete explicit type of thedefaultLoggerFragment(). Unfortunately, we have to spell it out instead of just letting it besome LoggerFragmentin order to define theConsoleLoggeralias properly.
Enumerations
enum ActivityIndicatorStatePossible states to draw / render andActivityIndicatorType.enum CommandErrorErrors working with theConsoleKitCommandsmodule.enum ConsoleClearSupported methods for clearing theConsole.enum ConsoleColorSupported colors for creating aConsoleStyleforConsoleText.enum ShellShell completion implementations.