Documentation ¶
Overview ¶
util package provides reusable functionality to the commands under pkg/cmd/time-entry, be it editing, creating, or rendering time entries
Index ¶
- Constants
- func AddPrintMultipleTimeEntriesFlags(cmd *cobra.Command)
- func AddPrintTimeEntriesFlags(cmd *cobra.Command, of *OutputFlags)
- func AddTimeEntryDateFlags(cmd *cobra.Command)
- func AddTimeEntryFlags(cmd *cobra.Command, f cmdutil.Factory, of *OutputFlags)
- func PrintTimeEntries(tes []dto.TimeEntry, out io.Writer, config cmdutil.Config, of OutputFlags) error
- func PrintTimeEntry(te *dto.TimeEntry, out io.Writer, config cmdutil.Config, of OutputFlags) error
- func PrintTimeEntryImpl(tei dto.TimeEntryImpl, f cmdutil.Factory, out io.Writer, of OutputFlags) error
- func TimeEntryDTOToImpl(t TimeEntryDTO) dto.TimeEntryImpl
- type DescriptionSuggestFn
- type OutputFlags
- type Step
- func CreateTimeEntryFn(c api.Client) Step
- func FillTimeEntryWithFlags(flags flagSet) Step
- func GetAllowNameForIDsFn(config cmdutil.Config, c api.Client) Step
- func GetDatesInteractiveFn(f cmdutil.Factory) Step
- func GetPropsInteractiveFn(dc DescriptionSuggestFn, f cmdutil.Factory) Step
- func GetValidateTimeEntryFn(f cmdutil.Factory) Step
- func OutInProgressFn(c api.Client) Step
- func ValidateClosingTimeEntry(f cmdutil.Factory) Step
- type TimeEntryDTO
Constants ¶
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 ¶
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 ¶
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 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
PrintTimeEntry 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
PrintTimeEntryImpl will print out a time entries using parameters and flags
func TimeEntryDTOToImpl ¶ added in v0.44.1
func TimeEntryDTOToImpl(t TimeEntryDTO) dto.TimeEntryImpl
TimeEntryDTOToImpl returns a TimeEntryImpl using the information from a TimeEntryDTO
Types ¶
type DescriptionSuggestFn ¶
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 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
type Step ¶ added in v0.44.1
type Step func(TimeEntryDTO) (TimeEntryDTO, error)
Step is used to stack multiple actions to be executed over a TimeEntryDTO
func CreateTimeEntryFn ¶
CreateTimeEntryFn will create a time entry
func FillTimeEntryWithFlags ¶
func FillTimeEntryWithFlags(flags flagSet) Step
FillTimeEntryWithFlags will read the flags and fill the time entry with they
func GetAllowNameForIDsFn ¶
GetAllowNameForIDsFn will try to find project/task/tags by their names if the value provided was not a ID
func GetDatesInteractiveFn ¶
GetDatesInteractiveFn will ask the user the start and end times of the entry
func GetPropsInteractiveFn ¶
func GetPropsInteractiveFn( dc DescriptionSuggestFn, f cmdutil.Factory, ) Step
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 ¶
GetValidateTimeEntryFn will check if the time entry is valid given the workspace parameters
func OutInProgressFn ¶
OutInProgressFn will stop the in progress time entry, if it exists
func ValidateClosingTimeEntry ¶
ValidateClosingTimeEntry checks if the current time entry will fail to be stopped
type TimeEntryDTO ¶ added in v0.44.1
type TimeEntryDTO struct { ID string Workspace string UserID string ProjectID string TaskID string Description string Start time.Time End *time.Time TagIDs []string Billable *bool Locked *bool }
TimeEntryDTO is used to keep and update the data of a time entry before changing it, taking into account optional values (nil)
func Do ¶
func Do(te TimeEntryDTO, cbs ...Step) (TimeEntryDTO, error)
Do will runs all callback functions over the time entry, keeping the changes and returning it after
func TimeEntryImplToDTO ¶ added in v0.44.1
func TimeEntryImplToDTO(t dto.TimeEntryImpl) TimeEntryDTO
TimeEntryImplToDTO returns a TimeEntryDTO using the information from a TimeEntryImpl