Documentation
¶
Overview ¶
utils/utils.go
Index ¶
- func ConfirmAction(message string) bool
- func FormatDate(t time.Time) string
- func FormatDateShort(t time.Time) string
- func GetBaseName(path string) string
- func GetLinkedProject() (string, error)
- func GetProjectIDOrLinked(projectID string) (string, error)
- func GetStatusIcon(status string) string
- func HandleError(err error, message string, opts OutputOptions)
- func IsLinkedProject() bool
- func IsValidURL(testURL string) bool
- func PrintError(message string, opts OutputOptions)
- func PrintInfo(message string, opts OutputOptions)
- func PrintJSON(data interface{}) error
- func PrintProjectContext(projectID string)
- func PrintProjectContextWithOptions(projectID string, opts OutputOptions)
- func PrintSuccess(message string, opts OutputOptions)
- func PrintTable(headers []string, rows [][]string, opts OutputOptions)
- func PrintWarning(message string, opts OutputOptions)
- func PromptUser(message string) (string, error)
- func PromptUserWithDefault(message, defaultValue string) string
- func RequireAuth(client interface{ ... }, opts OutputOptions) bool
- func RunCommand(name string, args ...string) (string, error)
- func SaveProjectContext(context *ProjectContext) error
- func TruncateString(s string, length int) string
- func ValidateOrPrompt() error
- func WithJSONOutput(fn func() (interface{}, error), opts OutputOptions) error
- type OutputFormat
- type OutputOptions
- type ProjectContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfirmAction ¶ added in v0.0.4
ConfirmAction asks user for confirmation
func FormatDate ¶ added in v0.0.4
FormatDate formats a date for display
func FormatDateShort ¶ added in v0.0.4
FormatDateShort formats a date in short format
func GetBaseName ¶ added in v0.0.4
GetBaseName returns the base name of a directory path
func GetLinkedProject ¶ added in v0.0.4
GetLinkedProject returns the project ID linked to the current directory
func GetProjectIDOrLinked ¶ added in v0.0.4
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
GetStatusIcon returns an emoji icon for status
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 ¶
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
PromptUser prompts user for input with a message
func PromptUserWithDefault ¶ added in v0.0.4
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 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
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