diff options
| author | felix <felix@seconddrawer.com.au> | 2011-05-19 07:13:20 +0000 |
|---|---|---|
| committer | felix <felix@seconddrawer.com.au> | 2011-05-19 07:13:20 +0000 |
| commit | db665f2e38e024a5bdf74a3c5fb00efb85fe1964 (patch) | |
| tree | b67f06761dbacbfe504a036b2ad669d352dc72cc | |
| parent | 40783e93cc2ed3770c8ca421779254f23d75530d (diff) | |
| download | timetrackr-db665f2e38e024a5bdf74a3c5fb00efb85fe1964.tar.gz timetrackr-db665f2e38e024a5bdf74a3c5fb00efb85fe1964.tar.bz2 | |
notes in log and task renaming
| -rwxr-xr-x | bin/timetrackr | 9 | ||||
| -rw-r--r-- | lib/timetrackr.rb | 7 | ||||
| -rw-r--r-- | lib/timetrackr/sqlite.rb | 5 | ||||
| -rw-r--r-- | lib/timetrackr/yaml.rb | 7 |
4 files changed, 27 insertions, 1 deletions
diff --git a/bin/timetrackr b/bin/timetrackr index 9ad99a7..1a3c2ba 100755 --- a/bin/timetrackr +++ b/bin/timetrackr @@ -138,7 +138,8 @@ when 'log' start = period.start.strftime(config['absolute_time']) stop = period.current? ? ' ' : period.stop.strftime(config['absolute_time']) length = format_time(period.length, config['relative_format']) - "#{day.ljust(12)} #{name.ljust(15)} #{start.ljust(7)} #{stop.ljust(7)} #{length}" + notes = period.notes + "#{day.ljust(12)} #{name.ljust(15)} #{start} - #{stop.ljust(5)} #{length} #{notes}" } puts table @@ -151,6 +152,12 @@ when 'clear','delete','del' puts "Task '#{task}' cleared" if $verbose end +when 'rename','mv' + from = ARGV.shift + to = ARGV.shift + trackr.rename(from,to) + puts "Renamed '#{from}' to '#{to}'" if $verbose + else puts "'#{cmd}' is not a valid command" show_help diff --git a/lib/timetrackr.rb b/lib/timetrackr.rb index c9c4fff..ae3165b 100644 --- a/lib/timetrackr.rb +++ b/lib/timetrackr.rb @@ -69,6 +69,13 @@ class TimeTrackr end # + # rename a task + # + def rename(from, to) + raise 'Not implemented' + end + + # # clear an task # def clear(task) diff --git a/lib/timetrackr/sqlite.rb b/lib/timetrackr/sqlite.rb index 2660376..99d95c4 100644 --- a/lib/timetrackr/sqlite.rb +++ b/lib/timetrackr/sqlite.rb @@ -57,6 +57,11 @@ class SqliteTimeTrackr < TimeTrackr } end + def rename(from, to) + sql = "UPDATE events SET task = :to WHERE task = :from;" + @db.execute(sql, 'to' => to, 'from' => from) + end + def clear(task) sql = "DELETE FROM events WHERE task = :task;" @db.execute(sql, 'task' => task) diff --git a/lib/timetrackr/yaml.rb b/lib/timetrackr/yaml.rb index f3547bc..2c02e23 100644 --- a/lib/timetrackr/yaml.rb +++ b/lib/timetrackr/yaml.rb @@ -51,6 +51,13 @@ class YamlTimeTrackr < TimeTrackr } unless !@db[:tasks].include? task end + def rename(from, to) + @db[:tasks][to] = @db[:tasks].delete(from) + if @db[:current].delete(from) + @db[:current].unshift(to) + end + end + def close write_file end |
