Go SDK: ux
Supported methods
The following UX elements are supported by the Golang SDK:
- ProgressBars
- Spinners
To create a UX element in your workflow, you need to create a new UX object.
Alternatively, the Ux object is included in the Client object:
func (*Ux) Bold
func (*Ux) Bold(text string) string
Formats text as boldface for printing with Print
or as a message in any of the other Ux
or Prompt
methods.
Formats correctly in the terminal and in Slack.
Example:
func (*Ux) Italic
func (*Ux) Italic(text string) string
Formats text as italic for printing with Print
or as a message in any of the other Ux
or Prompt
methods.
Formats correctly in the terminal and in Slack, but terminal support for italic text is limited.
Example:
func (*Ux) Print
func (*Ux) Print(text string) error
Prints text to the output interface (e.g. terminal or Slack).
Example:
Output:
func (*Ux) ProgressBarAdvance
func (*Ux) ProgressBarAdvance(increment int) error
ProgressBarAdvance adds onto a progressbar that is already present on the interface (e.g. terminal or Slack).
The increment
indicates the additional length (out of total length) that will be filled.
Example:
Output:
func (*Ux) ProgressBarStart
func (*Ux) ProgressBarStart(length, initial int, message string) error
ProgressBarStart presents a progressbar on the output interface (i.e. terminal or slack) that will stay present until the progressbar stop method is called.
The input length
is the total length of the progress bar, e.g. if you have 5 steps in your logic, then a unit length of 5 might be an appropriate length.
The initial
length indicates the unit length (out of total length) that is initially filled at the start.
Example:
Output:
func (*Ux) ProgressBarStop
func (*Ux) ProgressBarStop(message string) error
ProgressBarStop completes a progressbar that is already present on the interface (i.e. terminal or Slack).
The message
will change the initial text (set from the ux.ProgressBarStart
method).
Example:
Output:
func (*Ux) SpinnerStart
func (*Ux) SpinnerStart(text string) error
SpinnerStart presents a spinner on the output interface (e.g. terminal or Slack) that will spin until the SpinnerStop method is called.
Example:
Output:
func (*Ux) SpinnerStop
func (*Ux) SpinnerStop(text string) error
SpinnerStop stops a spinner that has been previously started on the interface (e.g. terminal or Slack).
Example:
Output: