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.

rdial.cmdline.fsck(ctx, globs)

Check storage consistency.

Parameters
rdial.cmdline.start(globs, task, new, time)

Start task.

Parameters
  • globs (AttrDict) – Global options object

  • task (str) – Task name to operate on

  • continue (bool) – Pull task name from last running task

  • new (bool) – Create a new task

  • time (datetime.datetime) – Task start time

rdial.cmdline.stop(globs, message, fname, amend)

Stop task.

Parameters
  • globs (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(globs, task, new, time, message, fname)

Complete last task and start new one.

Parameters
  • globs (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(globs, task, new, time, message, fname, command)

Run timed command.

Parameters
  • globs (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(ctx, globs, time, message, fname, wrapper)

Run predefined timed command.

Parameters
  • ctx (click.Context) – Click context object

  • globs (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(globs, task, stats, duration, sort, reverse, style)

Report time tracking data.

Parameters
  • globs (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(globs)

Display running task, if any.

Parameters

globs (AttrDict) – Global options object

rdial.cmdline.last(globs)

Display last event, if any.

Parameters

globs (AttrDict) – Global options object

rdial.cmdline.ledger(globs, task, duration, rate)

Generate ledger compatible data file.

Parameters
  • globs (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(ctx, directory, backup, cache, config, interactive, colour)[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='all')[source]

Filter events for report processing.

Parameters
  • globs (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!

list_commands(ctx)[source]

List visible commands.

Parameters

ctx (click.Context) – Current command context

Returns

Visible command names

Return type

list

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.

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.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.

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