Command line

Note

The documentation in this section is aimed at people wishing to contribute to rdial, and can be skipped if you are simply using the tool from the command line.

Commands

rdial.cmdline.bug_data()

Produce data for rdial bug reports.

Note

Ugly implementation follows…

The problems arise with Python’s package support. There is no well supported and generic interface to the information we want.

This would be easier, more useful and considerably more elegant using the infrastructure pip provides, but pip is a huge and ridiculous dependency just for this purpose. And one that isn’t available on many of the systems I care about anyway, and even when it appears to be available it is simply a shim to workaround otherwise broken packages that depend on its behaviour.

It is possible that we should simply defer to pip for those systems which have it and do something else for others, but the pip route would basically never be tested which is clearly bad.

rdial.cmdline.fsck()

Check storage consistency.

Parameters:
rdial.cmdline.start()

Start task.

Parameters:
rdial.cmdline.stop()

Stop task.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • message (str) – Message to assign to event
  • fname (str) – Filename to read message from
  • amend (bool) – Amend a previously stopped event
rdial.cmdline.switch()

Complete last task and start new one.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • task (str) – Task name to operate on
  • new (bool) – Create a new task
  • time (datetime.datetime) – Task start time
  • message (str) – Message to assign to event
  • fname (str) – Filename to read message from
rdial.cmdline.run()

Run timed command.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • task (str) – Task name to operate on
  • new (bool) – Create a new task
  • time (datetime.datetime) – Task start time
  • message (str) – Message to assign to event
  • fname (str) – Filename to read message from
  • command (str) – Command to run
rdial.cmdline.wrapper()

Run predefined timed command.

Parameters:
  • ctx (click.Context) – Click context object
  • globs (utils.AttrDict) – Global options object
  • time (datetime.datetime) – Task start time
  • message (str) – Message to assign to event
  • fname (str) – Filename to read message from
  • wrapper (str) – Run wrapper to execute
rdial.cmdline.report()

Report time tracking data.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • task (str) – Task name to operate on
  • stats (bool) – Display short overview of data
  • duration (str) – Time window to filter on
  • sort (str) – Key to sort events on
  • reverse (bool) – Reverse sort order
  • style (str) – Table formatting style
rdial.cmdline.running()

Display running task, if any.

Parameters:globs (utils.AttrDict) – Global options object
rdial.cmdline.last()

Display last event, if any.

Parameters:globs (utils.AttrDict) – Global options object
rdial.cmdline.ledger()

Generate ledger compatible data file.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • task (str) – Task name to operate on
  • duration (str) – Time window to filter on
  • rate (str) – Rate to assign hours in report

Entry points

rdial.cmdline.cli()[source]

Main command entry point.

Parameters:
  • ctx (click.Context) – Current command context
  • directory (str) – Location to store event data
  • backup (bool) – Whether to create backup files
  • cache (bool) – Whether to create cache files
  • config (str) – Location of config file
  • interactive (bool) – Whether to support interactive message editing
rdial.cmdline.main()[source]

Command entry point to handle errors.

Returns:Final exit code
Return type:int

Command support

rdial.cmdline.filter_events(globs, task=None, duration=None)[source]

Filter events for report processing.

Parameters:
  • globs (utils.AttrDict) – Global options object
  • task (str) – Task name to filter on
  • duration (str) – Time window to filter on
Returns:

Events matching specified criteria

Return type:

Events

rdial.cmdline.get_stop_message(current, edit=False)[source]

Interactively fetch stop message.

Parameters:
  • current (events.Event) – Current task
  • edit (bool) – Whether to edit existing message
Returns:

Message to use

Return type:

str

CLI support

class rdial.cmdline.HiddenGroup(name=None, commands=None, **attrs)[source]

Support for ‘hidden’ commands.

Any click.Command with the hidden attribute set will not be visible in help output. This is mainly to be used for diagnostic commands, and shouldn’t be abused!

class rdial.cmdline.TaskNameParamType[source]

Task name parameter handler.

convert(value, param, ctx)[source]

Check given task name is valid.

Parameters:
Returns:

Valid task name

Return type:

str

class rdial.cmdline.StartTimeParamType[source]

Start time parameter handler.

convert(value, param, ctx)[source]

Check given start time is valid.

Parameters:
Returns:

Valid start time

Return type:

datetime.datetime

rdial.cmdline.task_from_dir(ctx, param, value)[source]

Override task name default using name of current directory.

Parameters:
rdial.cmdline.task_option(fun)[source]

Add task selection options.

Parameters:fun (types.FunctionType) – Function to add options to
Returns:Function with additional options
Return type:types.FunctionType
rdial.cmdline.duration_option(fun)[source]

Add duration selection option.

Note

This is only here to reduce duplication in command setup.

Parameters:fun (types.FunctionType) – Function to add options to
Returns:Function with additional options
Return type:types.FunctionType
rdial.cmdline.message_option(fun)[source]

Add message setting options.

Parameters:fun (types.FunctionType) – Function to add options to
Returns:Function with additional options
Return type:types.FunctionType