progressPrinter

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Copyright (C) 2021-2023, Kubefirst

This program is licensed under MIT. See the LICENSE file for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTracker

func AddTracker(key string, title string, total int64) string

AddTracker Add Tracker (prefered way) Return a string for the key to be used on future uses Sample of usage:

progressPrinter.AddTracker("step-base", "Apply Base ", 3)

no need to instanciate, it is a singleton, only one instance already started before use.

func CreateTracker

func CreateTracker(title string, total int64) *progress.Tracker

CreateTracker Initialise a tracker object

Prefer `AddTracker` to create trackers, due to simplicity.

func GetInstance

func GetInstance() *progressPrinter

GetInstance Function used to initialize the component once in the execution. Usually called from the `cmd` `init` func or as early as possible on the execution.

import ("github.com/kubefirst/runtime/pkg")
func init() {
		progressPrinter.GetInstance()
		progressPrinter.SetupProgress(5) // Number of bars for the entire run.
}

func IncrementTracker

func IncrementTracker(key string, value int64)

IncrementTracker Increments a tracker based on the provided key if key is unkown it will error out. Sample of usage:

progressPrinter.IncrementTracker("step-base", 1)

func LogMessage

func LogMessage(message string)

LogMessage Prints a log message near the current active tracker. Sample of usage:

progressPrinter.LogMessage("- Waiting bootstrap")

func SetupProgress

func SetupProgress(numTrackers int, silentMode bool)

SetupProgress prepare the progress bar setting its initial configuration Used for general initialization of tracker object and overall counter

func TotalOfTrackers

func TotalOfTrackers() int

TotalOfTrackers Returns the number of initialized Trackers

Types

type ActionTracker

type ActionTracker struct {
	Tracker *progress.Tracker
}

ActionTracker Struct used to manage tracker object This object may evolve with more properties in th future when we have more fancier UI tools/styles.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL