utils

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasePath = "cli/cmd/.sst"
)

BasePath is the root directory for the .sst configuration files (relative to the current working directory).

Variables

This section is empty.

Functions

func BoolToYesNo

func BoolToYesNo(b bool) string

Converts boolean to "yes" or "no"

func CleanQuotes

func CleanQuotes(s string) string

func DumpBboltFromDB

func DumpBboltFromDB(db *bbolt.DB, bucketPath string) error

func ExplainRemoteRepositoryOpenError

func ExplainRemoteRepositoryOpenError(target string, err error) (friendly string, includeDetails bool)

ExplainRemoteRepositoryOpenError returns a short, user-oriented message for a failed OpenRemoteRepository. If includeDetails is true, the caller may also print the raw error.

func FlagToSymbol

func FlagToSymbol(flag sst.DiffTripleFlag) string

flagToSymbol returns a visual symbol for a DiffFlag

func GetAuthContext

func GetAuthContext(repo sst.Repository, authContexts map[sst.Repository]context.Context) context.Context

GetAuthContext returns the appropriate context for a given repository. If the repository has an associated authentication context (e.g., for remote repositories), it returns that context. Otherwise, it returns context.TODO() as a fallback for local or unauthenticated use.

func GetRealProvider

func GetRealProvider() *refreshableProvider

GetRealProvider retrieves a valid authentication provider, prompting user if necessary

func GetToken

func GetToken(refreshToken string) *oauth2.Token

func GetUserCredentials

func GetUserCredentials() (string, string)

GetUserCredentials prompts the user to enter their username and password

func HumanBytes

func HumanBytes(n int64) string

HumanBytes formats bytes into a human-friendly string.

func ListCommitHistoryDetailed

func ListCommitHistoryDetailed(dataset sst.Dataset, commit sst.Hash, visited map[string]bool, ctx context.Context)

func ListCommitHistoryHashOnly

func ListCommitHistoryHashOnly(dataset sst.Dataset, commit sst.Hash, visited map[string]bool, ctx context.Context)

func MuteLog

func MuteLog()

MuteLog redirects log output to a null device, effectively silencing it.

func MuteStdout

func MuteStdout()

MuteStdout redirects stdout to a null device, effectively silencing fmt.Printf and similar output.

func PaginateLogEntries

func PaginateLogEntries(entries [][]string, pageSize int)

PaginateLogEntries paginates log entries where each entry is a group of lines.

func PaginateOutput

func PaginateOutput(lines []string, linesPerPage int)

PaginateOutput displays a list of lines with pagination, pausing every `linesPerPage` lines. Users can press Enter to continue or type 'q' to exit early.

func PrintCommitDetails

func PrintCommitDetails(details *sst.CommitDetails)

func PrintDiffTriples

func PrintDiffTriples(tris []sst.DiffTriple)

Print a list of diff triples

func PrintDocumentInfo

func PrintDocumentInfo(doc *sst.DocumentInfo)

func PrintDocumentList

func PrintDocumentList(docs []sst.DocumentInfo)

func PrintIBNodeDetails

func PrintIBNodeDetails(alias string, node sst.IBNode)

func PrintNamedGraphDetails

func PrintNamedGraphDetails(alias string, namedGraph sst.NamedGraph)

func PrintNamedGraphInfo

func PrintNamedGraphInfo(info sst.NamedGraphInfo)

func PrintRepositoryInfo

func PrintRepositoryInfo(info sst.RepositoryInfo)

func PrintSearchResult

func PrintSearchResult(result *bleve.SearchResult)

func PrintSearchResultAllFields

func PrintSearchResultAllFields(result *bleve.SearchResult)

PrintSearchResultAllFields prints all fields from search results

func PrintStageInfo

func PrintStageInfo(stage sst.Stage)

func RemoveAlias

func RemoveAlias(list []string, alias string) []string

RemoveAlias removes a specific alias string from a list of aliases (generic utility)

func RemoveAliasFlag

func RemoveAliasFlag(args []string) []string

RemoveAliasFlag removes the first occurrence of '-a' flag and its value from args. This is useful when you need to get multiple aliases from the same args list.

func RestoreLog

func RestoreLog()

RestoreLog restores the log output to its original destination.

func RestoreStdout

func RestoreStdout()

RestoreStdout restores stdout to its original destination.

func ShowLoadingIndicator

func ShowLoadingIndicator(message string, fn func())

ShowLoadingIndicator runs a loading message or spinner while executing a given function. - `message`: The message to display while loading. - `fn`: The function that takes time to execute.

func SstDiffTriples

func SstDiffTriples(ctx context.Context, repo sst.Repository, oldH, newH sst.Hash, normalize bool) ([]sst.DiffTriple, error)

Compute diff triples between two NGRs

func SstRead

func SstRead(ctx context.Context, repo sst.Repository, h sst.Hash) ([]byte, error)

Read the raw SST bytes of a NamedGraphRevision (NGR)

func ValidatePath

func ValidatePath(path string) error

func VerifyTokenValidity

func VerifyTokenValidity(accessToken string) bool

VerifyTokenValidity checks if the token is a valid JWT

func WrapText

func WrapText(text string, width int, indentSize int) string

Types

type AliasResult

type AliasResult struct {
	Alias   string
	Confirm func() // Call this function only if the operation succeeds
}

AliasResult contains an alias and a confirmation function. If the alias was auto-generated, call Confirm() on success.

func GetAlias

func GetAlias(args []string, resourceType string) (AliasResult, error)

GetAlias checks if an alias is provided with '-a', if not, generates a default alias. Returns an AliasResult with the alias and a Confirm function. Call result.Confirm() only if the operation succeeds.

Jump to

Keyboard shortcuts

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