Sha256: 60a7f2a89c8a9bd4efcd08fd0d12144d8c9520a2ff00d4457a40091ed94817f3

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

#!/usr/bin/env ruby
require 'gli'
require 'fileutils'
require 'csv'
require 'date'

require 'doro'

# Initialization
Process.setproctitle("doro")
include GLI::App
doro_file = "#{Dir.home}/.doro"
program_desc 'A minimalist pomodoro application'
version Doro::VERSION
subcommand_option_handling :normal
arguments :strict

# Begin CLI
desc 'Displays completed pomodoros'
arg_name '*no arguments*'
command :list do |c|

  c.desc 'Number of pomodoros to show'
  c.default_value 10
  c.flag :n

  c.action do |global_options,options,args|
    Doro::Entries::display_entries(doro_file: doro_file, num_entries: options[:n].to_i)
  end

end

desc 'Begins a pomodoro timer'
arg_name '*description of task* (eg. cool task)'
command :start do |c|

  c.desc 'Tag task'
  c.default_value 'untagged'
  c.flag :t, type: String

  c.action do |global_options,options,args|
    raise "You didn't specify a task" if args.empty?
    task_name = args.join(' ')
    start_time = Time.now
    seconds = 0

    ProgressBar.new(task_name, 1500).start do
      seconds +=1
    end

    Doro::Entries::add_entry(
      doro_file: doro_file,
      task_name: task_name,
      minutes: seconds / 60,
      start_time: start_time,
      tag: options[:t]
    )

  end
end

desc 'Begins a break timer'
arg_name '*none*'
command :break do |c|

  c.desc 'Long (15 min) break'
  c.switch :long

  c.desc 'Set time in minutes'
  c.default_value 5
  c.flag :t, type: Integer

  c.action do |global_options,options,args|

    minutes = options[:t]
    options[:long]? minutes = 15 : nil

    ProgressBar.new('Break', minutes * 60).start do

    end

  end
end

pre do |global,command,options,args|
  FileUtils::touch doro_file unless File.file? doro_file
  true
end

post do |global,command,options,args|
end

on_error do |exception|
  true
end

exit run(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doro-0.2.4 bin/doro