utils

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

utils/utils.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmAction added in v0.0.4

func ConfirmAction(message string) bool

ConfirmAction asks user for confirmation

func FormatDate added in v0.0.4

func FormatDate(t time.Time) string

FormatDate formats a date for display

func FormatDateShort added in v0.0.4

func FormatDateShort(t time.Time) string

FormatDateShort formats a date in short format

func GetBaseName added in v0.0.4

func GetBaseName(path string) string

GetBaseName returns the base name of a directory path

func GetLinkedProject added in v0.0.4

func GetLinkedProject() (string, error)

GetLinkedProject returns the project ID linked to the current directory

func GetProjectIDOrLinked added in v0.0.4

func GetProjectIDOrLinked(projectID string) (string, error)

GetProjectIDOrLinked returns the provided project ID or the linked project ID If projectID is provided, it uses that. Otherwise, it tries to get the linked project.

func GetStatusIcon added in v0.0.4

func GetStatusIcon(status string) string

GetStatusIcon returns an emoji icon for status

func HandleAuthError added in v0.2.9

func HandleAuthError(err error, opts OutputOptions) bool

HandleAuthError handles authentication errors with specific messaging

func HandleError added in v0.0.4

func HandleError(err error, message string, opts OutputOptions)

HandleError handles errors consistently across commands

func IsLinkedProject added in v0.0.4

func IsLinkedProject() bool

IsLinkedProject checks if current directory has a linked project

func IsValidURL

func IsValidURL(testURL string) bool

IsValidURL checks if the provided string is a valid URL.

func PrintError added in v0.0.4

func PrintError(message string, opts OutputOptions)

PrintError prints an error message with emoji

func PrintInfo added in v0.0.4

func PrintInfo(message string, opts OutputOptions)

PrintInfo prints an info message with emoji

func PrintJSON added in v0.0.4

func PrintJSON(data interface{}) error

PrintJSON prints data as JSON

func PrintProjectContext added in v0.0.4

func PrintProjectContext(projectID string)

PrintProjectContext prints information about the current project context

func PrintProjectContextWithOptions added in v0.0.4

func PrintProjectContextWithOptions(projectID string, opts OutputOptions)

PrintProjectContextWithOptions prints project context information with output options

func PrintSuccess added in v0.0.4

func PrintSuccess(message string, opts OutputOptions)

PrintSuccess prints a success message with emoji

func PrintTable added in v0.0.4

func PrintTable(headers []string, rows [][]string, opts OutputOptions)

PrintTable prints data in a table format

func PrintWarning added in v0.0.4

func PrintWarning(message string, opts OutputOptions)

PrintWarning prints a warning message with emoji

func PromptUser added in v0.0.4

func PromptUser(message string) (string, error)

PromptUser prompts user for input with a message

func PromptUserWithDefault added in v0.0.4

func PromptUserWithDefault(message, defaultValue string) string

PromptUserWithDefault prompts user for input with a default value

func RequireAuth added in v0.0.4

func RequireAuth(client interface{ IsAuthenticated() bool }, opts OutputOptions) bool

RequireAuth checks if user is authenticated and prints error if not

func RunCommand

func RunCommand(name string, args ...string) (string, error)

func RunCommandWithEnv added in v0.2.10

func RunCommandWithEnv(name string, args []string, env []string) (string, error)

RunCommandWithEnv runs a command with custom environment variables

func SaveProjectContext added in v0.0.4

func SaveProjectContext(context *ProjectContext) error

SaveProjectContext saves project context to .pipeops/project.json

func TruncateString added in v0.0.4

func TruncateString(s string, length int) string

TruncateString truncates a string to the specified length

func ValidateOrPrompt

func ValidateOrPrompt() error

func WithJSONOutput added in v0.0.4

func WithJSONOutput(fn func() (interface{}, error), opts OutputOptions) error

WithJSONOutput wraps a function to support JSON output

Types

type OutputFormat added in v0.0.4

type OutputFormat string

OutputFormat represents the output format type

const (
	OutputFormatTable OutputFormat = "table"
	OutputFormatJSON  OutputFormat = "json"
)

type OutputOptions added in v0.0.4

type OutputOptions struct {
	Format  OutputFormat
	Quiet   bool
	Verbose bool
}

OutputOptions contains options for output formatting

func GetOutputOptions added in v0.0.4

func GetOutputOptions(cmd *cobra.Command) OutputOptions

GetOutputOptions extracts output options from command flags

type ProjectContext added in v0.0.4

type ProjectContext struct {
	ProjectID   string    `json:"project_id"`
	ProjectName string    `json:"project_name"`
	Directory   string    `json:"directory"`
	LinkedAt    time.Time `json:"linked_at"`
}

ProjectContext represents the context of a linked project

func LoadProjectContext added in v0.0.4

func LoadProjectContext() (*ProjectContext, error)

LoadProjectContext loads project context from .pipeops/project.json

Jump to

Keyboard shortcuts

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