internal

package
v0.0.0-...-57850c5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APP_MODE = "user"
View Source
var FILE_LOG = ""
View Source
var GCLI_4POSTMAN_HOME = os.Getenv("GCLI_4POSTMAN_HOME")
View Source
var HTTP_BODY_SIZE_LIMIT = 5000
View Source
var SECRET = ""

Functions

func AddCMDHistory

func AddCMDHistory(c Context, cmd string)

AddCMDHistory historises the command {cmd} (writes data on the disk).

func FindPromptActionExecutor

func FindPromptActionExecutor[T PromptExecutor](actions []PromptAction) *T

FindPromptActionExecutor finds the prompt action executor {T}.

func GetHomeFilePath

func GetHomeFilePath(file string) string

func GetHomeWorkspaceFilePath

func GetHomeWorkspaceFilePath(workspaceName, file string) string

func GetHomeWorkspacePath

func GetHomeWorkspacePath(workspaceName string) string

func HasRightToExecute

func HasRightToExecute(p PromptAction, in []string, role string) bool

HasRightToExecute checks if the prompt action {p} can be executed based on user input and current mode.

Types

type CMDHistories

type CMDHistories []CMDHistory

func (CMDHistories) GetName

func (s CMDHistories) GetName() []string

GetName returns the CMD history

type CMDHistory

type CMDHistory struct {
	CMD        string
	ExecutedAt time.Time
}

func NewCMDHistory

func NewCMDHistory(cmd string) CMDHistory

type Context

type Context struct {
	WorkspaceName  string
	CollectionName string

	Collection *postman.Collection
	Env        *postman.Env
	Envs       []postman.Env

	CollectionHistoryRequests postman.CollectionHistoryItems
	CMDsHistory               CMDHistories

	Log   logger.Logger
	Print func(string, string, ...any)
}

func NewContext

func NewContext(
	log logger.Logger,
	print func(string, string, ...any)) *Context

func (*Context) AddCollectionHistoryRequest

func (c *Context) AddCollectionHistoryRequest(i postman.CollectionHistoryItem)

func (*Context) Clean

func (c *Context) Clean()

func (*Context) GetCMDHistoryPath

func (c *Context) GetCMDHistoryPath() string

func (*Context) GetCollectionHistoryPath

func (c *Context) GetCollectionHistoryPath() string

func (*Context) GetCollectionPath

func (c *Context) GetCollectionPath() string

func (*Context) GetEnvName

func (c *Context) GetEnvName() string

func (*Context) GetEnvPath

func (c *Context) GetEnvPath(env postman.Env) string

func (*Context) GetWorkspacePath

func (c *Context) GetWorkspacePath() string

type Option

type Option struct {
	Value       string
	Description string
}

type ParamWithRole

type ParamWithRole struct {
	Value string
	Roles []string
}

type PromptAction

type PromptAction interface {
	// GetName returns the name of the action
	GetName() string

	// GetDescription returns the action's description (for "help" cmd)
	GetDescription(markdown bool) string

	// GetOptions returns the action's options can be used (for "help" cmd)
	GetOptions(markdown bool) []Option

	// GetActionKeys returns the command(s) (load, :l) which should used to use this prompt action
	GetActionKeys() []string

	// GetParamKeys returns the param(s) (-update-readme, -secure-mode) which should used to use this prompt action
	GetParamKeys() []ParamWithRole

	// GetPromptExecutor builds the action's executor used to execute commands
	GetPromptExecutor() PromptExecutor

	// PromptSuggest returns the action's suggests available
	PromptSuggest(in []string, d prompt.Document) ([]prompt.Suggest, error)

	// PromptExecutor executes action's command and can return a callback
	PromptExecutor(in []string) *PromptCallback

	// PromptCallback executes command after callback - often used to have user confirmation
	PromptCallback(in []string, actions []PromptAction, args ...any)
}

PromptAction interface which defines how to implement a new prompt action

type PromptCallback

type PromptCallback struct {
	Text         string
	Callbacks    []PromptSuggestCallback
	PromptAction PromptAction
	Args         []any
}

func NewPromptCallback

func NewPromptCallback(text string, callbacks []PromptSuggestCallback, promptAction PromptAction, args ...any) *PromptCallback

func (PromptCallback) Callback

func (p PromptCallback) Callback(in []string, actions []PromptAction)

func (PromptCallback) GetSuggests

func (p PromptCallback) GetSuggests() []prompt.Suggest

func (PromptCallback) IsAvailableAnswer

func (p PromptCallback) IsAvailableAnswer(in string) bool

type PromptExecutor

type PromptExecutor interface{}

type PromptSuggestCallback

type PromptSuggestCallback struct {
	Text        string
	Description string
}

func NewPromptSuggestCallback

func NewPromptSuggestCallback(text string, desc string) PromptSuggestCallback

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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