util

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HelpTimeEntryNowIfNotSet = "If no start time (`--when`) is set then the " +
		"current time will be used.\n"

	HelpInteractiveByDefault = "By default, the CLI will ask the " +
		"information interactively; use `--interactive=0` to disable it.\n" +
		"\n" +
		"If you prefer that it never don't do that by default, " +
		"run the bellow command, and use `--interactive` when you want " +
		"to be asked:\n" +
		"```\n" +
		"$ clockify-cli config set interactive false\n" +
		"```\n"

	HelpDateTimeFormats = "" +
		` - Full Date and Time:                "2016-02-01 15:04:05"` + "\n" +
		` - Date and Time (assumes 0 seconds): "2016-02-01 15:04"` + "\n" +
		` - Yesterday with Time:               "yesterday 15:04:05"` + "\n" +
		` - Yesterday with Time (0 seconds):   "yesterday 15:04"` + "\n" +
		` - Today at Time:                     "15:04:05"` + "\n" +
		` - Today at Time (assumes 0 seconds): "15:04"` + "\n" +
		` - 10mins in the future:              +10m` + "\n" +
		` - 1min and 30s ago:                  -90s` + "\n" +
		` - 1hour and 10min ago:               -1:10s` + "\n" +
		` - 1day, 10min and 30s ago:           -1d10m30s` + "\n"

	HelpTimeInputOnTimeEntry = "When setting a date/time input " +
		"(`--when` and `--when-to-close`) you can use any of the following " +
		"formats to set then:\n" +
		HelpDateTimeFormats

	HelpNamesForIds = "To be able to use names of resources instead of its " +
		"IDs you must enable the feature 'allow-name-for-id', to do that " +
		"run the command (the commands may take longer to look for the " +
		"resource id):\n" +
		"```\n" +
		"$ clockify-cli config set allow-name-for-id true\n" +
		"```\n\n"

	HelpValidateIncomplete = "By default, the CLI (and Clockify API) only " +
		"validates if the workspace and project rules are respected when a " +
		"time entry is stopped, if you prefer to validate when " +
		"starting/inserting it run the following command:\n" +
		"```\n" +
		"$ clockify-cli config set allow-incomplete false\n" +
		"```\n\n"

	HelpMoreInfoAboutStarting = "Use `clockify-cli in --help` for more " +
		"information about creating new time entries."

	HelpMoreInfoAboutPrinting = "Use `clockify-cli report --help` for more " +
		"information about printing time entries."

	HelpTimeEntriesAliasForEdit = "" +
		`If you want to edit the current (running) time entry you can ` +
		`use "` + timeentryhlp.AliasCurrent + `" instead of its ID.` + "\n" +
		`To edit the last ended time entry you can use "` +
		timeentryhlp.AliasLast + `" for it, for the one before that you ` +
		`can use "^2", for the previous "^3" and so on.` + "\n"
)

Variables

This section is empty.

Functions

func AddPrintMultipleTimeEntriesFlags

func AddPrintMultipleTimeEntriesFlags(cmd *cobra.Command)

AddPrintMultipleTimeEntriesFlags add flags to print multiple time entries

func AddPrintTimeEntriesFlags

func AddPrintTimeEntriesFlags(cmd *cobra.Command, of *OutputFlags)

AddPrintTimeEntriesFlags add flags common to time entry print

func AddTimeEntryDateFlags

func AddTimeEntryDateFlags(cmd *cobra.Command)

AddTimeEntryDateFlags adds the default start and end flags

func AddTimeEntryFlags

func AddTimeEntryFlags(
	cmd *cobra.Command, f cmdutil.Factory, of *OutputFlags,
)

AddTimeEntryFlags will add the common flags needed to add/edit a time entry

func Do

func Do(te dto.TimeEntryImpl, cbs ...DoFn) (
	dto.TimeEntryImpl, error)

Do will runs all callback functions over the time entry, keeping the changes and returning it after

func PrintTimeEntries

func PrintTimeEntries(
	tes []dto.TimeEntry, out io.Writer, config cmdutil.Config, of OutputFlags,
) error

PrintTimeEntries will print out a list of time entries using parameters and flags

func PrintTimeEntry

func PrintTimeEntry(
	te *dto.TimeEntry, out io.Writer, config cmdutil.Config, of OutputFlags,
) error

PrintTimeEntries will print out a time entries using parameters and flags

func PrintTimeEntryImpl

func PrintTimeEntryImpl(
	tei dto.TimeEntryImpl,
	f cmdutil.Factory,
	out io.Writer,
	of OutputFlags,
) error

PrintTimeEntries will print out a time entries using parameters and flags

Types

type DescriptionSuggestFn

type DescriptionSuggestFn func(string) []string

DescriptionSuggestFn provides suggestions to user when setting the description of a time entry

func NewDescriptionCompleter

func NewDescriptionCompleter(f cmdutil.Factory) DescriptionSuggestFn

NewDescriptionCompleter create or not a descriptionCompleter based on params

type DoFn

type DoFn func(dto.TimeEntryImpl) (dto.TimeEntryImpl, error)

func CreateTimeEntryFn

func CreateTimeEntryFn(c api.Client) DoFn

CreateTimeEntryFn will create a time entry

func FillTimeEntryWithFlags

func FillTimeEntryWithFlags(flags *pflag.FlagSet) DoFn

FillTimeEntryWithFlags will read the flags and fill the time entry with they

func GetAllowNameForIDsFn

func GetAllowNameForIDsFn(config cmdutil.Config, c api.Client) DoFn

GetAllowNameForIDsFn will try to find project/task/tags by their names if the value provided was not a ID

func GetDatesInteractiveFn

func GetDatesInteractiveFn(config cmdutil.Config) DoFn

GetDatesInteractiveFn will ask the user the start and end times of the entry

func GetPropsInteractiveFn

func GetPropsInteractiveFn(
	c api.Client,
	dc DescriptionSuggestFn,
	config cmdutil.Config,
) DoFn

GetPropsInteractiveFn will return a callback that asks the user interactively about the properties of the time entry, only if the parameter cmdutil.CONF_INTERACTIVE is active

func GetValidateTimeEntryFn

func GetValidateTimeEntryFn(f cmdutil.Factory) DoFn

GetValidateTimeEntryFn will check if the time entry is valid given the workspace parameters

func OutInProgressFn

func OutInProgressFn(c api.Client) DoFn

OutInProgressFn will stop the in progress time entry, if it exists

func ValidateClosingTimeEntry

func ValidateClosingTimeEntry(f cmdutil.Factory) DoFn

ValidateClosingTimeEntry checks if the current time entry will fail to be stopped

type OutputFlags

type OutputFlags struct {
	Format            string
	CSV               bool
	JSON              bool
	Quiet             bool
	Markdown          bool
	DurationFormatted bool
	DurationFloat     bool

	TimeFormat string
}

OutputFlags sets how to print out a list of time entries

func (OutputFlags) Check

func (of OutputFlags) Check() error

Jump to

Keyboard shortcuts

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