timetrap 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -32,7 +32,7 @@ All commands can be abbreviated.
32
32
 
33
33
  Each timesheet contains *entries*. Each entry has a start and end time, and a
34
34
  note associated with it. An entry without an end time set is considered to be
35
- *running*.
35
+ running.
36
36
 
37
37
  You check in to the current sheet with the `in` command.
38
38
 
@@ -199,9 +199,9 @@ Commands
199
199
 
200
200
  **sheet**
201
201
  Switch to a timesheet creating it if necessary. The default timesheet is
202
- called "default".
202
+ called "default". When no sheet is specified list all existing sheets.
203
203
 
204
- usage: ``t sheet TIMESHEET``
204
+ usage: ``t sheet [TIMESHEET]``
205
205
 
206
206
  **week**
207
207
  Shortcut for display with start date set to monday of this week
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 6
4
- :patch: 0
4
+ :patch: 1
data/lib/timetrap/cli.rb CHANGED
@@ -51,8 +51,6 @@ COMMAND is one of:
51
51
  configurable (see configure)
52
52
  -m, --move <sheet> Move to another sheet
53
53
 
54
- * format - Deprecated: alias for display.
55
-
56
54
  * in - Start the timer for the current timesheet.
57
55
  usage: t in [--at TIME] [NOTES]
58
56
  -a, --at <time:qs> Use this time instead of now
@@ -71,12 +69,9 @@ COMMAND is one of:
71
69
  usage: t out [--at TIME] [TIMESHEET]
72
70
  -a, --at <time:qs> Use this time instead of now
73
71
 
74
- * running - Deprecated: alias for now.
75
-
76
- * sheet - Switch to a timesheet creating it if necessary.
77
- usage: t sheet TIMESHEET
78
-
79
- * switch - Deprecated: renamed to sheet.
72
+ * sheet - Switch to a timesheet creating it if necessary. When no sheet is
73
+ specified list all sheets.
74
+ usage: t sheet [TIMESHEET]
80
75
 
81
76
  * week - Shortcut for display with start date set to monday of this week.
82
77
  usage: t week [--ids] [--end DATE] [--format FMT] [SHEET | all]
@@ -121,17 +116,33 @@ COMMAND is one of:
121
116
  Timetrap::CLI::USAGE.scan(/\* \w+/).map{|s| s.gsub(/\* /, '')}
122
117
  end
123
118
 
119
+ def deprecated_commands
120
+ {
121
+ 'switch' => 'sheet',
122
+ 'running' => 'now',
123
+ 'format' => 'display'
124
+ }
125
+ end
126
+
124
127
  def invoke_command_if_valid
125
128
  command = args.unused.shift
126
129
  set_global_options
127
130
  case (valid = commands.select{|name| name =~ %r|^#{command}|}).size
128
- when 0 then puts "Invalid command: #{command}"
131
+ when 1 then send valid[0]
129
132
  else
130
- if command
131
- send valid[0]
132
- else
133
- puts USAGE
134
- end
133
+ handle_invalid_command(command)
134
+ end
135
+ end
136
+
137
+ def handle_invalid_command(command)
138
+ if !command
139
+ puts USAGE
140
+ elsif mapping = deprecated_commands.detect{|(k,v)| k =~ %r|^#{command}|}
141
+ deprecated, current = *mapping
142
+ warn "The #{deprecated.inspect} command is deprecated in favor of #{current.inspect}. Sorry for the inconvenience."
143
+ send current
144
+ else
145
+ warn "Invalid command: #{command.inspect}"
135
146
  end
136
147
  end
137
148
 
@@ -246,20 +257,17 @@ COMMAND is one of:
246
257
  puts fmt_klass.new(entries).output
247
258
  end
248
259
  end
249
- alias_method :format, :display
250
260
 
251
261
  def sheet
252
262
  sheet = unused_args
253
263
  unless sheet =~ /.+/
254
- warn "No sheet specified"
264
+ list
255
265
  else
256
266
  Timer.current_sheet = sheet
257
267
  warn "Switching to sheet #{sheet.inspect}"
258
268
  end
259
269
  end
260
270
 
261
- alias_method :switch, :sheet
262
-
263
271
  def list
264
272
  sheets = ([Timer.current_sheet] | Entry.sheets).map do |sheet|
265
273
  sheet_atts = {:total => 0, :running => 0, :today => 0}
@@ -301,7 +309,6 @@ COMMAND is one of:
301
309
  puts out
302
310
  end
303
311
  end
304
- alias_method :running, :display
305
312
 
306
313
  def week
307
314
  args['-s'] = Date.today.wday == 1 ? Date.today.to_s : Date.parse(Chronic.parse(%q(last monday)).to_s).to_s
@@ -44,6 +44,14 @@ describe Timetrap do
44
44
  end
45
45
  end
46
46
 
47
+ describe 'with an invalid command' do
48
+ it "should tell me I'm wrong" do
49
+ invoke 'poo'
50
+ $stderr.string.should include 'Invalid command: "poo"'
51
+ end
52
+ end
53
+
54
+
47
55
  describe 'archive' do
48
56
  before do
49
57
  3.times do |i|
@@ -279,6 +287,12 @@ Grand Total 10:00:00
279
287
  create_entry(:start => '2008-10-05 12:00:00', :end => '2008-10-05 14:00:00')
280
288
  end
281
289
  describe 'csv' do
290
+ it "should be deprecated" do
291
+ invoke 'format'
292
+ $stderr.string.should == <<-WARN
293
+ The "format" command is deprecated in favor of "display". Sorry for the inconvenience.
294
+ WARN
295
+ end
282
296
 
283
297
  it "should not export running items" do
284
298
  invoke 'in'
@@ -579,6 +593,12 @@ END:VCALENDAR
579
593
  invoke 'sheet'
580
594
  Timetrap::Timer.current_sheet.should == 'sheet 1'
581
595
  end
596
+
597
+ it "should list timesheets when there are no arguments" do
598
+ invoke 'sheet sheet 1'
599
+ invoke 'sheet'
600
+ $stdout.string.should == " Timesheet Running Today Total Time\n*sheet 1 0:00:00 0:00:00 0:00:00\n"
601
+ end
582
602
  end
583
603
  end
584
604
  end
data/timetrap.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{timetrap}
8
- s.version = "1.6.0"
8
+ s.version = "1.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Goldstein"]
12
- s.date = %q{2010-11-28}
12
+ s.date = %q{2010-11-29}
13
13
  s.default_executable = %q{t}
14
14
  s.description = %q{Command line time tracker}
15
15
  s.email = %q{sgrock@gmail.com}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetrap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 0
10
- version: 1.6.0
9
+ - 1
10
+ version: 1.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Goldstein
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-28 00:00:00 -08:00
18
+ date: 2010-11-29 00:00:00 -08:00
19
19
  default_executable: t
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency