[][src]Struct doug::Doug

pub struct Doug { /* fields omitted */ }

Doug, a time tracking command-line utility.

This is the backend where all the logic for Doug is kept. The current implementation uses $HOME/.doug/ for storing data, while the CLI stuff is handled by [clap] in main.rs.

Methods

impl Doug[src]

pub fn new(path: Option<&str>) -> Result<Self, String>[src]

Initialize a new Doug instance

If missing, the data file will be created at $HOME/.doug/periods.json.

Arguments

  • path — an optional path to the root of the data folder.

Examples

// Create a new Doug instance with default data location
let doug = Doug::new(None).unwrap();

let doug = Doug::new(Some(&tempdir)).unwrap();

pub fn load_periods_from_file(
    data_file: &File,
    settings: Settings,
    settings_location: PathBuf
) -> Result<Self, String>
[src]

pub fn status(
    &self,
    simple_name: bool,
    simple_time: bool
) -> Result<Option<String>, String>
[src]

Log currently running project, duration of current period, and the datetime tracking started.

If there is no running project, logs No running project. The CLI returns exit code 1.

See arguments to refine the output of this command.

Arguments

  • simple_name — Print just the name of the currently running project, or nothing.
  • simple_time — Print just the current time, formated with format::duration.

Examples

// We don't want to mess with existing installations
// with no running project, this will return Err
doug.status(false, false).expect_err("No running project");

doug.start("test");

// no args
doug.status(false, false).expect("Should return Ok");

// simple_name
doug.status(true, false).expect("Should return Ok");

// simple_time
doug.status(false, true).expect("Should be fine too");

pub fn settings(
    &mut self,
    path: Option<&str>,
    clear: bool
) -> Result<Option<String>, String>
[src]

pub fn save(&mut self) -> Result<Option<String>, String>[src]

Save period data to file.

A backup of the data file will be made before serializing the data.

pub fn start(&mut self, project_name: &str) -> Result<Option<String>, String>[src]

Start tracking a project.

In the CLI, we call Doug::restart if no project_name is provided.

Arguments

  • project_name — name of project to start tracking a new period with.

pub fn amend(&mut self, project_name: &str) -> Result<Option<String>, String>[src]

Change name of currently running period.

Will exit 1 if there isn't any running project.

pub fn report(
    &self,
    past_years: i32,
    past_months: i32,
    past_weeks: i32,
    past_days: i32,
    from_date: Option<&str>,
    to_date: Option<&str>
) -> Result<Option<String>, String>
[src]

Aggregate periods per project.

pub fn delete(&mut self, project_name: &str) -> Result<Option<String>, String>[src]

Remove all periods for a project

Arguments

  • project_name — project to remove

pub fn restart(&mut self) -> Result<Option<String>, String>[src]

Restart last running period

pub fn log(&self) -> Result<Option<String>, String>[src]

List periods in chronological order

pub fn cancel(&mut self) -> Result<Option<String>, String>[src]

Stop current period and remove log entry

pub fn stop(&mut self) -> Result<Option<String>, String>[src]

Stop current period and save stop time

pub fn edit(
    &mut self,
    start: Option<&str>,
    end: Option<&str>
) -> Result<Option<String>, String>
[src]

Edit last running period.

If no arguments are provided, the data file is open $EDITOR.

Arguments

  • start — date to set start time of last period.
  • end — date to set end time of last period.

Both arguments accept humanized dates (e.g. thursday 9:00am, today 12:15pm)

pub fn merge(
    &mut self,
    file_path: &str,
    dry_run: bool
) -> Result<Option<String>, String>
[src]

Merge period file

If two periods have conflicting end times, the one with the earlier end time will be used.

Trait Implementations

impl Clone for Doug[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Doug

impl Sync for Doug

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.