standup_md 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9e2449a7136b2b9b9633db530b2304ddc986050bb404c951cb0da1cb299330b
4
- data.tar.gz: 52106b7870dee25cf07070fd6e6ff689c84e3142bdb1249077f8ea757d56eac1
3
+ metadata.gz: 171d0b1fdd697049f52d50db4d1b0ccb95db648dc70b67957c612ebdf74c57b2
4
+ data.tar.gz: 1c2347af65439e1d8263715eeb3d9b45b4cbc020793ddb1a51dbbd71ee71159b
5
5
  SHA512:
6
- metadata.gz: 27248294c5f4d85bb5b1c4ae5df44d4133bfbe968acc30aba3917df29424f00b56c56bb12ea1219fe0b0c2ce311699f912957f616526db5ee43939c11abf7def
7
- data.tar.gz: dfc856d09518702f57bc7fdb2a1610ce5143c165340709e067a4509ca7fc7789bd247422f6ac3952a678006789dc939a8f8e12b7f318b3e63cec140dab5c82b3
6
+ metadata.gz: faca92ff7d839b8fb83c579bc203ba3477e975d225f2fd7ef5c3c8b37625a674ed6a7e89e7f9033c2169f5cc6f52c0e7ae9a046fb29880bd95f1ac7a56bc400c
7
+ data.tar.gz: f365e31e43288e039e9c35b887f905a5def1233200d34fead1a250df79215f107cc5ff16534e503d074f1e2b29620fad64b285f94ce68042226cc3a6a1e04fcf
@@ -1,4 +1,5 @@
1
- name: Ruby
1
+ # .github/workflows/ruby.yml
2
+ name: Ruby CI
2
3
 
3
4
  on:
4
5
  push:
@@ -8,17 +9,31 @@ on:
8
9
 
9
10
  jobs:
10
11
  test:
12
+ runs-on: ubuntu-22.04
11
13
 
12
- runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby-version: ['3.2', '3.3', '4.0']
13
18
 
14
19
  steps:
15
- - uses: actions/checkout@v2
16
- - name: Set up Ruby 2.6
17
- uses: actions/setup-ruby@v1
18
- with:
19
- ruby-version: 2.6.x
20
- - name: Build and test with Rake
21
- run: |
22
- gem install bundler
23
- bundle install
24
- bundle exec rake test
20
+ - uses: actions/checkout@v3
21
+
22
+ # Set up Ruby and Bundler
23
+ - name: Set up Ruby ${{ matrix.ruby-version }}
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler: ${{ matrix.ruby-version == '4.0' && '4.0.9' || '2.4.13' }}
28
+ bundler-cache: true
29
+
30
+ - name: Print Ruby and Bundler versions
31
+ run: |
32
+ ruby -v
33
+ bundle -v
34
+
35
+ - name: Install dependencies
36
+ run: bundle install --jobs 4 --retry 3
37
+
38
+ - name: Run tests
39
+ run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,31 +1,126 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- standup_md (0.3.13)
4
+ standup_md (0.3.16)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- docile (1.3.5)
10
- power_assert (2.0.0)
11
- rake (13.0.3)
12
- simplecov (0.21.2)
9
+ ast (2.4.3)
10
+ date (3.5.1)
11
+ docile (1.4.1)
12
+ erb (6.0.4)
13
+ json (2.19.9)
14
+ language_server-protocol (3.17.0.5)
15
+ lint_roller (1.1.0)
16
+ parallel (1.28.0)
17
+ parser (3.3.11.1)
18
+ ast (~> 2.4.1)
19
+ racc
20
+ power_assert (3.0.1)
21
+ prism (1.9.0)
22
+ psych (5.4.0)
23
+ date
24
+ stringio
25
+ racc (1.8.1)
26
+ rainbow (3.1.1)
27
+ rake (13.4.2)
28
+ rdoc (7.2.0)
29
+ erb
30
+ psych (>= 4.0.0)
31
+ tsort
32
+ regexp_parser (2.12.0)
33
+ rubocop (1.84.2)
34
+ json (~> 2.3)
35
+ language_server-protocol (~> 3.17.0.2)
36
+ lint_roller (~> 1.1.0)
37
+ parallel (~> 1.10)
38
+ parser (>= 3.3.0.2)
39
+ rainbow (>= 2.2.2, < 4.0)
40
+ regexp_parser (>= 2.9.3, < 3.0)
41
+ rubocop-ast (>= 1.49.0, < 2.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 2.4.0, < 4.0)
44
+ rubocop-ast (1.49.1)
45
+ parser (>= 3.3.7.2)
46
+ prism (~> 1.7)
47
+ rubocop-performance (1.26.1)
48
+ lint_roller (~> 1.1)
49
+ rubocop (>= 1.75.0, < 2.0)
50
+ rubocop-ast (>= 1.47.1, < 2.0)
51
+ ruby-progressbar (1.13.0)
52
+ simplecov (0.22.0)
13
53
  docile (~> 1.1)
14
54
  simplecov-html (~> 0.11)
15
55
  simplecov_json_formatter (~> 0.1)
16
- simplecov-html (0.12.3)
17
- simplecov_json_formatter (0.1.2)
18
- test-unit (3.4.1)
56
+ simplecov-html (0.13.2)
57
+ simplecov_json_formatter (0.1.4)
58
+ standard (1.54.0)
59
+ language_server-protocol (~> 3.17.0.2)
60
+ lint_roller (~> 1.0)
61
+ rubocop (~> 1.84.0)
62
+ standard-custom (~> 1.0.0)
63
+ standard-performance (~> 1.8)
64
+ standard-custom (1.0.2)
65
+ lint_roller (~> 1.0)
66
+ rubocop (~> 1.50)
67
+ standard-performance (1.9.0)
68
+ lint_roller (~> 1.1)
69
+ rubocop-performance (~> 1.26.0)
70
+ stringio (3.2.0)
71
+ test-unit (3.7.8)
19
72
  power_assert
73
+ tsort (0.2.0)
74
+ unicode-display_width (3.2.0)
75
+ unicode-emoji (~> 4.1)
76
+ unicode-emoji (4.2.0)
20
77
 
21
78
  PLATFORMS
22
- x86_64-darwin-20
79
+ arm64-darwin-25
80
+ ruby
23
81
 
24
82
  DEPENDENCIES
25
83
  rake (~> 13.0, >= 13.0.1)
84
+ rdoc
26
85
  simplecov
86
+ standard (~> 1.54.0)
27
87
  standup_md!
28
88
  test-unit (~> 3.3, >= 3.3.5)
29
89
 
90
+ CHECKSUMS
91
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
92
+ date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
93
+ docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
94
+ erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
95
+ json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
96
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
97
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
98
+ parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970
99
+ parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
100
+ power_assert (3.0.1) sha256=8ce9876716cc74e863fcd4cdcdc52d792bd983598d1af3447083a3a9a4d34103
101
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
102
+ psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7
103
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
104
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
105
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
106
+ rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
107
+ regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
108
+ rubocop (1.84.2) sha256=5692cea54168f3dc8cb79a6fe95c5424b7ea893c707ad7a4307b0585e88dbf5f
109
+ rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035
110
+ rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
111
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
112
+ simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
113
+ simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
114
+ simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
115
+ standard (1.54.0) sha256=7a4b08f83d9893083c8f03bc486f0feeb6a84d48233b40829c03ef4767ea0100
116
+ standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
117
+ standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
118
+ standup_md (0.3.16)
119
+ stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
120
+ test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
121
+ tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
122
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
123
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
124
+
30
125
  BUNDLED WITH
31
- 2.2.16
126
+ 4.0.10
data/README.md CHANGED
@@ -6,10 +6,11 @@
6
6
 
7
7
  > The cure for all your standup woes.
8
8
 
9
- A highly customizable and automated way to keep track of daily standups in
10
- markdown files.
9
+ An automated, customizable way to keep track of daily standups in markdown
10
+ files.
11
11
 
12
- You can view the documentation [here](https://evanthegrayt.github.io/standup_md/).
12
+ You can view the documentation
13
+ [here](https://evanthegrayt.github.io/standup_md/).
13
14
 
14
15
  ## About
15
16
  I've now been at two separate companies where we post our daily standups in a
@@ -43,7 +44,7 @@ gem install standup_md
43
44
  To include in your project, add the following to your `Gemfile`.
44
45
 
45
46
  ```ruby
46
- gem 'standup_md'
47
+ gem "standup_md"
47
48
  ```
48
49
 
49
50
  ### Manual Installation
@@ -73,6 +74,14 @@ important; you may add new entries, but don't change any of the headers. Doing
73
74
  so will cause the parser to break. If you want to customize the headers, you can
74
75
  do so in the [configuration file](#available-config-file-options-and-defaults).
75
76
 
77
+ To open a previous month's standup file, pass the date as an argument. Both
78
+ `YYYY-MM` and `YYYY-MM-DD` are accepted, and both open the file for that month.
79
+
80
+ ```sh
81
+ standup 2026-06
82
+ standup 2026-06-18
83
+ ```
84
+
76
85
  ### CLI Examples
77
86
  #### Adding an entry for today via editor
78
87
  For example, if the standup entry from yesterday reads as follows:
@@ -150,36 +159,36 @@ rails project, create an initializer (`config/initializers/standup_md.rb`).
150
159
  StandupMD.configure do |c|
151
160
  # Defaults for how the file is formatted.
152
161
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
153
- c.file.header_date_format = '%Y-%m-%d'
162
+ c.file.header_date_format = "%Y-%m-%d"
154
163
  c.file.header_depth = 1
155
164
  c.file.sub_header_depth = 2
156
- c.file.current_header = 'Current'
157
- c.file.previous_header = 'Previous'
158
- c.file.impediments_header = 'Impediments'
159
- c.file.notes_header = 'Notes'
165
+ c.file.current_header = "Current"
166
+ c.file.previous_header = "Previous"
167
+ c.file.impediments_header = "Impediments"
168
+ c.file.notes_header = "Notes"
160
169
  c.file.sub_header_order = %w[previous current impediments notes]
161
- c.file.directory = ::File.join(ENV['HOME'], '.cache', 'standup_md')
162
- c.file.bullet_character = '-'
163
- c.file.name_format = '%Y_%m.md'
170
+ c.file.directory = ::File.join(ENV["HOME"], ".cache", "standup_md")
171
+ c.file.bullet_character = "-"
172
+ c.file.name_format = "%Y_%m.md"
164
173
  c.file.create = true
165
174
 
166
- # Defaults for entries
175
+ # Defaults for entries.
167
176
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Entry.html
168
177
  c.entry.current = ["<!-- ADD TODAY'S WORK HERE -->"]
169
178
  c.entry.previous = []
170
- c.entry.impediments = ['None']
179
+ c.entry.impediments = ["None"]
171
180
  c.entry.notes = []
172
181
 
173
182
  # Defaults for executable runtime behavior.
174
183
  # See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
175
184
  c.cli.date = Date.today
176
- c.cli.editor = 'vim' # Checks $VISUAL and $EDITOR first, in that order
185
+ c.cli.editor = "vim" # Checks $VISUAL and $EDITOR first, in that order
177
186
  c.cli.verbose = false
178
187
  c.cli.edit = true
179
188
  c.cli.write = true
180
189
  c.cli.print = false
181
190
  c.cli.auto_fill_previous = true
182
- c.cli.preference_file = ::File.expand_path(::File.join(ENV['HOME'], '.standuprc'))
191
+ c.cli.preference_file = ::File.expand_path(::File.join(ENV["HOME"], ".standuprc"))
183
192
  end
184
193
  ```
185
194
 
@@ -250,11 +259,11 @@ Your `~/.standuprc` should contain:
250
259
  StandupMD.configure do |c|
251
260
  c.file.header_depth = 2
252
261
  c.file.sub_header_depth = 3
253
- c.file.current_header = 'Today'
254
- c.file.previous_header = 'Yesterday'
255
- c.file.impediments_header = 'Hold-ups'
256
- c.file.bullet_character = '*'
257
- c.file.header_date_format = '%m/%d/%Y'
262
+ c.file.current_header = "Today"
263
+ c.file.previous_header = "Yesterday"
264
+ c.file.impediments_header = "Hold-ups"
265
+ c.file.bullet_character = "*"
266
+ c.file.header_date_format = "%m/%d/%Y"
258
267
  c.file.sub_header_order = %w[current previous impediments notes]
259
268
  end
260
269
  ```
@@ -270,14 +279,14 @@ new entry via code could look like the following:
270
279
  ### API Examples
271
280
  #### Adding an entry for today
272
281
  ```ruby
273
- require 'standup_md'
282
+ require "standup_md"
274
283
 
275
284
  StandupMD.configure do |c|
276
- c.file.current_header = 'Today',
285
+ c.file.current_header = "Today",
277
286
  end
278
287
 
279
288
  file = StandupMD::File.find_by_date(Date.today)
280
- entry = StandupMD::Entry.create { |e| e.current = ['Stuff I will do today'] }
289
+ entry = StandupMD::Entry.create { |e| e.current = ["Stuff I will do today"] }
281
290
  file.entries << entry
282
291
  file.write
283
292
  ```
@@ -286,11 +295,11 @@ The above example was written as such to show how the different pieces of the
286
295
  API fit together. The code can actually be simplified to the following.
287
296
 
288
297
  ```ruby
289
- require 'standup_md'
298
+ require "standup_md"
290
299
 
291
300
  StandupMD.configure do |c|
292
- c.file.current_header = 'Today',
293
- c.entry.current = ['Stuff I will do today']
301
+ c.file.current_header = "Today",
302
+ c.entry.current = ["Stuff I will do today"]
294
303
  end
295
304
 
296
305
  StandupMD::File.find_by_date(Date.today).load.write
@@ -298,7 +307,7 @@ StandupMD::File.find_by_date(Date.today).load.write
298
307
 
299
308
  #### Finding a past entry
300
309
  ```ruby
301
- require 'standup_md'
310
+ require "standup_md"
302
311
 
303
312
  date = Date.new(2020, 04, 15)
304
313
  file = StandupMD::File.find_by_date(date).load
data/Rakefile CHANGED
@@ -1,21 +1,86 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/standup_md'
4
- require 'bundler/gem_tasks'
5
- require 'rdoc/task'
6
- require 'rake/testtask'
3
+ $LOAD_PATH.unshift(File.expand_path("lib", __dir__))
4
+
5
+ require "standup_md"
6
+ require "bundler/gem_tasks"
7
+ require "rdoc/task"
8
+ require "rake/testtask"
9
+
10
+ STANDARD_FILES = ["lib", "test"].freeze
7
11
 
8
12
  Rake::TestTask.new do |t|
9
- t.libs = ['lib']
13
+ t.libs = ["lib"]
10
14
  t.warning = true
11
15
  t.verbose = true
12
- t.test_files = FileList['test/**/*_test.rb']
16
+ t.test_files = FileList["test/**/*_test.rb"]
13
17
  end
14
18
 
15
19
  RDoc::Task.new do |rdoc|
16
- rdoc.main = 'README.md'
17
- rdoc.rdoc_dir = 'docs'
18
- rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
20
+ rdoc.main = "README.md"
21
+ rdoc.rdoc_dir = "docs"
22
+ rdoc.rdoc_files.include("README.md", "lib/**/*.rb")
23
+ end
24
+
25
+ desc "Lint with the Standard Ruby style guide"
26
+ task :standard do
27
+ require "standard"
28
+
29
+ exit_code = Standard::Cli.new(STANDARD_FILES).run
30
+ fail unless exit_code.zero?
31
+ end
32
+
33
+ desc "Lint and automatically make safe fixes with the Standard Ruby style guide"
34
+ task :"standard:fix" do
35
+ require "standard"
36
+
37
+ exit_code = Standard::Cli.new(STANDARD_FILES + ["--fix"]).run
38
+ fail unless exit_code.zero?
19
39
  end
20
40
 
21
41
  task default: :test
42
+
43
+ namespace :version do
44
+ desc "Print the current version from the version.rb file"
45
+ task :current do
46
+ puts StandupMD::VERSION
47
+ end
48
+
49
+ namespace :increment do
50
+ desc "Increment the version's PATCH level"
51
+ task :patch do
52
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
53
+ File.write(
54
+ version_file,
55
+ File.read(version_file).sub(/(PATCH\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
56
+ )
57
+ end
58
+ system("bundle lock")
59
+ end
60
+ desc "Increment the version's MINOR level"
61
+ task :minor do
62
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
63
+ File.write(
64
+ version_file,
65
+ File.read(version_file)
66
+ .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" }
67
+ .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
68
+ )
69
+ end
70
+ system("bundle lock")
71
+ end
72
+ desc "Increment the version's MAJOR level"
73
+ task :major do
74
+ File.join(__dir__, "lib", "standup_md", "version.rb").then do |version_file|
75
+ File.write(
76
+ version_file,
77
+ File.read(version_file)
78
+ .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" }
79
+ .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}0" }
80
+ .sub(/(MAJOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" }
81
+ )
82
+ end
83
+ system("bundle lock")
84
+ end
85
+ end
86
+ end
data/bin/standup CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative '../lib/standup_md'
3
+ $LOAD_PATH.unshift(File.expand_path("../lib", __dir__))
4
+
5
+ require "standup_md"
4
6
 
5
7
  StandupMD::Cli.execute(ARGV)
@@ -20,7 +20,7 @@ module StandupMD
20
20
  next if !tasks || tasks.empty?
21
21
 
22
22
  puts sub_header(header_type)
23
- tasks.each { |task| puts config.file.bullet_character + ' ' + task }
23
+ tasks.each { |task| puts "#{config.file.bullet_character} #{task}" }
24
24
  end
25
25
  puts
26
26
  end
@@ -42,79 +42,84 @@ module StandupMD
42
42
  # @return [Hash]
43
43
  def load_runtime_preferences(options)
44
44
  OptionParser.new do |opts|
45
- opts.banner = 'The Standup Doctor'
45
+ opts.banner = "The Standup Doctor"
46
46
  opts.version = "[StandupMD] #{::StandupMD::Version}"
47
47
  opts.on(
48
- '--current ARRAY', Array,
48
+ "--current ARRAY", Array,
49
49
  "List of current entry's tasks"
50
50
  ) { |v| config.entry.current = v }
51
51
 
52
52
  opts.on(
53
- '--previous ARRAY', Array,
53
+ "--previous ARRAY", Array,
54
54
  "List of precious entry's tasks"
55
55
  ) { |v| config.entry.previous = v }
56
56
 
57
57
  opts.on(
58
- '--impediments ARRAY', Array,
59
- 'List of impediments for current entry'
58
+ "--impediments ARRAY", Array,
59
+ "List of impediments for current entry"
60
60
  ) { |v| config.entry.impediments = v }
61
61
 
62
62
  opts.on(
63
- '--notes ARRAY', Array,
64
- 'List of notes for current entry'
63
+ "--notes ARRAY", Array,
64
+ "List of notes for current entry"
65
65
  ) { |v| config.entry.notes = v }
66
66
 
67
67
  opts.on(
68
- '--sub-header-order ARRAY', Array,
69
- 'The order of the sub-headers when writing the file'
68
+ "--sub-header-order ARRAY", Array,
69
+ "The order of the sub-headers when writing the file"
70
70
  ) { |v| config.file.sub_header_order = v }
71
71
 
72
72
  opts.on(
73
- '-f', '--file-name-format STRING',
74
- 'Date-formattable string to use for standup file name'
73
+ "-f", "--file-name-format STRING",
74
+ "Date-formattable string to use for standup file name"
75
75
  ) { |v| config.file.name_format = v }
76
76
 
77
77
  opts.on(
78
- '-E', '--editor EDITOR',
79
- 'Editor to use for opening standup files'
78
+ "-E", "--editor EDITOR",
79
+ "Editor to use for opening standup files"
80
80
  ) { |v| config.cli.editor = v }
81
81
 
82
82
  opts.on(
83
- '-d', '--directory DIRECTORY',
84
- 'The directories where standup files are located'
83
+ "-d", "--directory DIRECTORY",
84
+ "The directories where standup files are located"
85
85
  ) { |v| config.file.directory = v }
86
86
 
87
87
  opts.on(
88
- '-w', '--[no-]write',
88
+ "-w", "--[no-]write",
89
89
  "Write current entry if it doesn't exist. Default is true"
90
90
  ) { |v| config.cli.write = v }
91
91
 
92
92
  opts.on(
93
- '-a', '--[no-]auto-fill-previous',
93
+ "-a", "--[no-]auto-fill-previous",
94
94
  "Auto-generate 'previous' tasks for new entries. Default is true"
95
95
  ) { |v| config.cli.auto_fill_previous = v }
96
96
 
97
97
  opts.on(
98
- '-e', '--[no-]edit',
99
- 'Open the file in the editor. Default is true'
98
+ "-e", "--[no-]edit",
99
+ "Open the file in the editor. Default is true"
100
100
  ) { |v| config.cli.edit = v }
101
101
 
102
102
  opts.on(
103
- '-v', '--[no-]verbose',
104
- 'Verbose output. Default is false.'
103
+ "-v", "--[no-]verbose",
104
+ "Verbose output. Default is false."
105
105
  ) { |v| config.cli.verbose = v }
106
106
 
107
107
  opts.on(
108
- '-p', '--print [DATE]',
109
- 'Print current entry.',
110
- 'If DATE is passed, will print entry for DATE, if it exists.',
111
- 'DATE must be in the same format as file-name-format'
108
+ "-p", "--print [DATE]",
109
+ "Print current entry.",
110
+ "If DATE is passed, will print entry for DATE, if it exists.",
111
+ "DATE must be in the same format as file-name-format"
112
112
  ) do |v|
113
113
  config.cli.print = true
114
114
  config.cli.date =
115
115
  v.nil? ? Date.today : Date.strptime(v, config.file.header_date_format)
116
116
  end
117
117
  end.parse!(options)
118
+ unless options.empty?
119
+ @file_date_argument = true
120
+ config.cli.date = parse_file_date(options.shift)
121
+ end
122
+ raise OptionParser::InvalidArgument, options.join(" ") unless options.empty?
118
123
  end
119
124
 
120
125
  ##
@@ -123,7 +128,7 @@ module StandupMD
123
128
  # @return [StandupMD::Entry]
124
129
  def new_entry(file)
125
130
  entry = file.entries.find(config.cli.date)
126
- return entry unless entry.nil? && config.cli.date == Date.today
131
+ return entry if read_only? || entry || config.cli.date != Date.today
127
132
 
128
133
  StandupMD::Entry.new(
129
134
  config.cli.date,
@@ -131,7 +136,7 @@ module StandupMD
131
136
  previous_entry(file),
132
137
  config.entry.impediments,
133
138
  config.entry.notes
134
- ).tap { |entry| file.entries << entry }
139
+ ).tap { |e| file.entries << e }
135
140
  end
136
141
 
137
142
  ##
@@ -145,6 +150,25 @@ module StandupMD
145
150
  prev_entry(file.entries)
146
151
  end
147
152
 
153
+ ##
154
+ # Parses the optional file date argument.
155
+ #
156
+ # @param [String] value
157
+ #
158
+ # @return [Date]
159
+ def parse_file_date(value)
160
+ case value
161
+ when /\A\d{4}-\d{2}-\d{2}\z/
162
+ Date.strptime(value, "%Y-%m-%d")
163
+ when /\A\d{4}-\d{2}\z/
164
+ Date.strptime(value, "%Y-%m")
165
+ else
166
+ raise OptionParser::InvalidArgument, value
167
+ end
168
+ rescue ArgumentError
169
+ raise OptionParser::InvalidArgument, value
170
+ end
171
+
148
172
  ##
149
173
  # The previous entry.
150
174
  #
@@ -170,7 +194,7 @@ module StandupMD
170
194
  #
171
195
  # @return [String]
172
196
  def header(entry)
173
- '#' * config.file.header_depth + ' ' +
197
+ "#" * config.file.header_depth + " " +
174
198
  entry.date.strftime(config.file.header_date_format)
175
199
  end
176
200
 
@@ -181,7 +205,7 @@ module StandupMD
181
205
  #
182
206
  # @return [String]
183
207
  def sub_header(header_type)
184
- '#' * config.file.sub_header_depth + ' ' +
208
+ "#" * config.file.sub_header_depth + " " +
185
209
  config.file.public_send("#{header_type}_header").capitalize
186
210
  end
187
211
  end