cmdutil

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONF_WORKWEEK_DAYS                    = "workweek-days"
	CONF_INTERACTIVE                      = "interactive"
	CONF_ALLOW_NAME_FOR_ID                = "allow-name-for-id"
	CONF_SEARCH_PROJECTS_WITH_CLIENT_NAME = "search-project-with-client"
	CONF_USER_ID                          = "user.id"
	CONF_WORKSPACE                        = "workspace"
	CONF_TOKEN                            = "token"
	CONF_ALLOW_INCOMPLETE                 = "allow-incomplete"
	CONF_SHOW_TASKS                       = "show-task"
	CONF_SHOW_CLIENT                      = "show-client"
	CONF_DESCR_AUTOCOMP                   = "description-autocomplete"
	CONF_DESCR_AUTOCOMP_DAYS              = "description-autocomplete-days"
	CONF_SHOW_TOTAL_DURATION              = "show-total-duration"
	CONF_LOG_LEVEL                        = "log-level"
	CONF_ALLOW_ARCHIVED_TAGS              = "allow-archived-tags"
	CONF_INTERACTIVE_PAGE_SIZE            = "interactive-page-size"
)
View Source
const (
	LOG_LEVEL_NONE  = "none"
	LOG_LEVEL_DEBUG = "debug"
	LOG_LEVEL_INFO  = "info"
)

Variables

This section is empty.

Functions

func AddProjectFlags

func AddProjectFlags(cmd *cobra.Command, f Factory)

AddProjectFlags creates a project flag with autocomplete configured

func GetWeekdays

func GetWeekdays() []string

GetWeekdays with their names

func RequiredNamedArgs

func RequiredNamedArgs(names ...string) cobra.PositionalArgs

RequiredNamedArgs will fail if the number of arguments received is less than the length of the parameter `names`, and will show the help explaining required named arguments

func XorFlag

func XorFlag(exclusiveFlags map[string]bool) error

XorFlag will fail if 2 or more entries are true

func XorFlagSet added in v0.40.0

func XorFlagSet(f *pflag.FlagSet, exclusiveFlags ...string) error

XorFlagSet works like XorFlag, but will read if the flag was changed from the pflag.FlagSet

Types

type Config

type Config interface {
	// GetBool retrieves a config by its name as a bool
	GetBool(string) bool
	// SetBool changes a bool config by its name
	SetBool(string, bool)

	// GetInt retrieves a config by its name as a int
	GetInt(string) int
	// SetInt changes a int config by its name
	SetInt(string, int)

	// GetString retrieves a config by its name as a string
	GetString(string) string
	// SetString changes a string config by its name
	SetString(string, string)

	// SetStringSlice retrieves a config by its name as a []string
	GetStringSlice(string) []string
	// SetStringSlice changes a []string config by its name
	SetStringSlice(string, []string)

	// IsDebuging configures CLI to log most of the data being used
	IsDebuging() bool
	// IsAllowNameForID configures the CLI to lookup entities ids by their name
	IsAllowNameForID() bool
	// IsInteractive configures the CLI to prompt the user interactively
	IsInteractive() bool
	// GetWorkWeekdays set which days of the week the user is expected to work
	GetWorkWeekdays() []string
	// InteractivePageSize sets how many items are shown when prompting
	// projects
	InteractivePageSize() int
	// IsSearchProjectWithClientsName defines if the project name for ID should
	// include the client's name
	IsSearchProjectWithClientsName() bool

	// Get retrieves a config by its name
	Get(string) interface{}
	// All retrieves all the configurations of the CLI as a map
	All() map[string]interface{}

	// LogLevel sets how much should be logged during execution
	LogLevel() string

	// Save will persist the changes made to the configuration
	Save() error
}

Config manages configs and parameters used locally by the CLI

type Factory

type Factory interface {
	// Version of the CLI
	Version() Version

	// Config returns configurations set by the user
	Config() Config
	// Client builds a client for Clockify's API
	Client() (api.Client, error)
	// UI builds a control to prompt information from the user
	UI() ui.UI

	// GetUserID returns the current user id
	GetUserID() (string, error)
	// GetWorkspaceID returns the current workspace id
	GetWorkspaceID() (string, error)
	// GetWorkspaceID returns the current workspace
	GetWorkspace() (dto.Workspace, error)
}

Factory is a container/factory builder for the commands and its helpers

func NewFactory

func NewFactory(v Version) Factory

type FlagError

type FlagError struct {
	// contains filtered or unexported fields
}

FlagError happens when a non-cobra validation fails

func FlagErrorWrap

func FlagErrorWrap(err error) *FlagError

func (*FlagError) Error

func (fe *FlagError) Error() string

func (*FlagError) Unwrap

func (fe *FlagError) Unwrap() error

type Version

type Version struct {
	Tag    string
	Commit string
	Date   string
}

Version register which is the CLI tag, commit and build date

Jump to

Keyboard shortcuts

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