standup_md 0.3.15 → 0.3.17
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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +49 -28
- data/Rakefile +45 -0
- data/completion/zsh/_standup +80 -0
- data/lib/standup_md/cli/helpers.rb +36 -1
- data/lib/standup_md/cli.rb +122 -4
- data/lib/standup_md/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f155bb0cdeacfcf00716bfd5cfbc67a9e5d6d1d8be2b89c35d0f148ec782b264
|
|
4
|
+
data.tar.gz: fa9f7a3d971f45f79f2f819fcaa05c761bdf2cd3d9b4de3abc942b320ca4765d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b22a137af1ae2a03cead81ffce5b46f517721dd22f5364318e595ebe7e22d6b9eb7e2ed05021acaec9a3f5d0f76769c98d73a898ee908be58656c4d7f01a60f8
|
|
7
|
+
data.tar.gz: 5cbbf132c3cbec6e1b6290c1d1b13f8c7f8f25aa6b02d0e51052964b4688dcad7350488cc17810b1f87a9098bdcba21824e752c9fd7bbc71e21d3edeb86ab112
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
standup_md (0.3.
|
|
4
|
+
standup_md (0.3.17)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -115,7 +115,7 @@ CHECKSUMS
|
|
|
115
115
|
standard (1.54.0) sha256=7a4b08f83d9893083c8f03bc486f0feeb6a84d48233b40829c03ef4767ea0100
|
|
116
116
|
standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
|
|
117
117
|
standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
|
|
118
|
-
standup_md (0.3.
|
|
118
|
+
standup_md (0.3.17)
|
|
119
119
|
stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
|
|
120
120
|
test-unit (3.7.8) sha256=689d1ca53f4d46f678b4e5d68d8e4294f87fc5e8b9238cc4de7c5727e8d65943
|
|
121
121
|
tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
|
data/README.md
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
> The cure for all your standup woes.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
An automated, customizable way to keep track of daily standups in markdown
|
|
10
|
+
files.
|
|
11
11
|
|
|
12
|
-
You can view the documentation
|
|
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
|
|
47
|
+
gem "standup_md"
|
|
47
48
|
```
|
|
48
49
|
|
|
49
50
|
### Manual Installation
|
|
@@ -58,6 +59,17 @@ cd standup_md
|
|
|
58
59
|
rake install
|
|
59
60
|
```
|
|
60
61
|
|
|
62
|
+
### Zsh Completion
|
|
63
|
+
The gem ships with a zsh completion file at `completion/zsh/_standup`. RubyGems
|
|
64
|
+
doesn't automatically add gem-provided completion directories to zsh's `fpath`,
|
|
65
|
+
so you'll need to add the completion directory yourself after installation.
|
|
66
|
+
|
|
67
|
+
For setup instructions and example, run the following.
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
standup --zsh-completion
|
|
71
|
+
```
|
|
72
|
+
|
|
61
73
|
## Usage
|
|
62
74
|
### Command Line
|
|
63
75
|
For the most basic usage, simply call the executable.
|
|
@@ -73,6 +85,14 @@ important; you may add new entries, but don't change any of the headers. Doing
|
|
|
73
85
|
so will cause the parser to break. If you want to customize the headers, you can
|
|
74
86
|
do so in the [configuration file](#available-config-file-options-and-defaults).
|
|
75
87
|
|
|
88
|
+
To open a previous month's standup file, pass the date as an argument. Both
|
|
89
|
+
`YYYY-MM` and `YYYY-MM-DD` are accepted, and both open the file for that month.
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
standup 2026-06
|
|
93
|
+
standup 2026-06-18
|
|
94
|
+
```
|
|
95
|
+
|
|
76
96
|
### CLI Examples
|
|
77
97
|
#### Adding an entry for today via editor
|
|
78
98
|
For example, if the standup entry from yesterday reads as follows:
|
|
@@ -150,36 +170,36 @@ rails project, create an initializer (`config/initializers/standup_md.rb`).
|
|
|
150
170
|
StandupMD.configure do |c|
|
|
151
171
|
# Defaults for how the file is formatted.
|
|
152
172
|
# See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
|
|
153
|
-
c.file.header_date_format =
|
|
173
|
+
c.file.header_date_format = "%Y-%m-%d"
|
|
154
174
|
c.file.header_depth = 1
|
|
155
175
|
c.file.sub_header_depth = 2
|
|
156
|
-
c.file.current_header =
|
|
157
|
-
c.file.previous_header =
|
|
158
|
-
c.file.impediments_header =
|
|
159
|
-
c.file.notes_header =
|
|
176
|
+
c.file.current_header = "Current"
|
|
177
|
+
c.file.previous_header = "Previous"
|
|
178
|
+
c.file.impediments_header = "Impediments"
|
|
179
|
+
c.file.notes_header = "Notes"
|
|
160
180
|
c.file.sub_header_order = %w[previous current impediments notes]
|
|
161
|
-
c.file.directory = ::File.join(ENV[
|
|
162
|
-
c.file.bullet_character =
|
|
163
|
-
c.file.name_format =
|
|
181
|
+
c.file.directory = ::File.join(ENV["HOME"], ".cache", "standup_md")
|
|
182
|
+
c.file.bullet_character = "-"
|
|
183
|
+
c.file.name_format = "%Y_%m.md"
|
|
164
184
|
c.file.create = true
|
|
165
185
|
|
|
166
|
-
# Defaults for entries
|
|
186
|
+
# Defaults for entries.
|
|
167
187
|
# See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Entry.html
|
|
168
188
|
c.entry.current = ["<!-- ADD TODAY'S WORK HERE -->"]
|
|
169
189
|
c.entry.previous = []
|
|
170
|
-
c.entry.impediments = [
|
|
190
|
+
c.entry.impediments = ["None"]
|
|
171
191
|
c.entry.notes = []
|
|
172
192
|
|
|
173
193
|
# Defaults for executable runtime behavior.
|
|
174
194
|
# See https://evanthegrayt.github.io/standup_md/doc/StandupMD/Config/Cli.html
|
|
175
195
|
c.cli.date = Date.today
|
|
176
|
-
c.cli.editor =
|
|
196
|
+
c.cli.editor = "vim" # Checks $VISUAL and $EDITOR first, in that order
|
|
177
197
|
c.cli.verbose = false
|
|
178
198
|
c.cli.edit = true
|
|
179
199
|
c.cli.write = true
|
|
180
200
|
c.cli.print = false
|
|
181
201
|
c.cli.auto_fill_previous = true
|
|
182
|
-
c.cli.preference_file = ::File.expand_path(::File.join(ENV[
|
|
202
|
+
c.cli.preference_file = ::File.expand_path(::File.join(ENV["HOME"], ".standuprc"))
|
|
183
203
|
end
|
|
184
204
|
```
|
|
185
205
|
|
|
@@ -205,6 +225,7 @@ Some of these options can be changed at runtime. They are as follows.
|
|
|
205
225
|
-a --[no-]auto-fill-previous Auto-generate 'previous' tasks for new entries
|
|
206
226
|
-e --[no-]edit Open the file in the editor. Default is true
|
|
207
227
|
-v, --[no-]verbose Verbose output. Default is false.
|
|
228
|
+
--zsh-completion Print zsh completion setup instructions
|
|
208
229
|
-p, --print [DATE] Print current entry.
|
|
209
230
|
If DATE is passed, will print entry for DATE, if it exists.
|
|
210
231
|
DATE must be in the same format as file-name-format
|
|
@@ -250,11 +271,11 @@ Your `~/.standuprc` should contain:
|
|
|
250
271
|
StandupMD.configure do |c|
|
|
251
272
|
c.file.header_depth = 2
|
|
252
273
|
c.file.sub_header_depth = 3
|
|
253
|
-
c.file.current_header =
|
|
254
|
-
c.file.previous_header =
|
|
255
|
-
c.file.impediments_header =
|
|
256
|
-
c.file.bullet_character =
|
|
257
|
-
c.file.header_date_format =
|
|
274
|
+
c.file.current_header = "Today"
|
|
275
|
+
c.file.previous_header = "Yesterday"
|
|
276
|
+
c.file.impediments_header = "Hold-ups"
|
|
277
|
+
c.file.bullet_character = "*"
|
|
278
|
+
c.file.header_date_format = "%m/%d/%Y"
|
|
258
279
|
c.file.sub_header_order = %w[current previous impediments notes]
|
|
259
280
|
end
|
|
260
281
|
```
|
|
@@ -270,14 +291,14 @@ new entry via code could look like the following:
|
|
|
270
291
|
### API Examples
|
|
271
292
|
#### Adding an entry for today
|
|
272
293
|
```ruby
|
|
273
|
-
require
|
|
294
|
+
require "standup_md"
|
|
274
295
|
|
|
275
296
|
StandupMD.configure do |c|
|
|
276
|
-
c.file.current_header =
|
|
297
|
+
c.file.current_header = "Today",
|
|
277
298
|
end
|
|
278
299
|
|
|
279
300
|
file = StandupMD::File.find_by_date(Date.today)
|
|
280
|
-
entry = StandupMD::Entry.create { |e| e.current = [
|
|
301
|
+
entry = StandupMD::Entry.create { |e| e.current = ["Stuff I will do today"] }
|
|
281
302
|
file.entries << entry
|
|
282
303
|
file.write
|
|
283
304
|
```
|
|
@@ -286,11 +307,11 @@ The above example was written as such to show how the different pieces of the
|
|
|
286
307
|
API fit together. The code can actually be simplified to the following.
|
|
287
308
|
|
|
288
309
|
```ruby
|
|
289
|
-
require
|
|
310
|
+
require "standup_md"
|
|
290
311
|
|
|
291
312
|
StandupMD.configure do |c|
|
|
292
|
-
c.file.current_header =
|
|
293
|
-
c.entry.current = [
|
|
313
|
+
c.file.current_header = "Today",
|
|
314
|
+
c.entry.current = ["Stuff I will do today"]
|
|
294
315
|
end
|
|
295
316
|
|
|
296
317
|
StandupMD::File.find_by_date(Date.today).load.write
|
|
@@ -298,7 +319,7 @@ StandupMD::File.find_by_date(Date.today).load.write
|
|
|
298
319
|
|
|
299
320
|
#### Finding a past entry
|
|
300
321
|
```ruby
|
|
301
|
-
require
|
|
322
|
+
require "standup_md"
|
|
302
323
|
|
|
303
324
|
date = Date.new(2020, 04, 15)
|
|
304
325
|
file = StandupMD::File.find_by_date(date).load
|
data/Rakefile
CHANGED
|
@@ -39,3 +39,48 @@ task :"standard:fix" do
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
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
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#compdef standup
|
|
2
|
+
|
|
3
|
+
_standup_array_values() {
|
|
4
|
+
_message -e values 'comma-separated list'
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
_standup_sub_header_order() {
|
|
8
|
+
local -a headers
|
|
9
|
+
|
|
10
|
+
headers=(
|
|
11
|
+
'previous:previous entry tasks'
|
|
12
|
+
'current:current entry tasks'
|
|
13
|
+
'impediments:current entry impediments'
|
|
14
|
+
'notes:current entry notes'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
_values -s , 'sub-header' $headers
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_standup_dates() {
|
|
21
|
+
local directory="${STANDUP_MD_DIR:-$HOME/.cache/standup_md}"
|
|
22
|
+
local index
|
|
23
|
+
local file
|
|
24
|
+
local -a dates
|
|
25
|
+
|
|
26
|
+
for (( index = 1; index <= $#words; index++ )); do
|
|
27
|
+
case "$words[index]" in
|
|
28
|
+
--directory=*)
|
|
29
|
+
directory="${words[index]#--directory=}"
|
|
30
|
+
;;
|
|
31
|
+
--directory|-d)
|
|
32
|
+
if (( index < $#words )); then
|
|
33
|
+
directory="$words[index + 1]"
|
|
34
|
+
fi
|
|
35
|
+
;;
|
|
36
|
+
esac
|
|
37
|
+
done
|
|
38
|
+
|
|
39
|
+
directory=${~directory}
|
|
40
|
+
if [[ -d "$directory" ]]; then
|
|
41
|
+
for file in "$directory"/*.md(N); do
|
|
42
|
+
file="${file:t:r}"
|
|
43
|
+
if [[ "$file" == <->_<-> ]]; then
|
|
44
|
+
dates+=("${file/_/-}:standup file ${file}.md")
|
|
45
|
+
fi
|
|
46
|
+
done
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
if (( ${#dates} )); then
|
|
50
|
+
_describe -t dates 'standup date' dates
|
|
51
|
+
else
|
|
52
|
+
_message -e dates 'date (YYYY-MM or YYYY-MM-DD)'
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_arguments -s -S \
|
|
57
|
+
'(- *)'{-h,--help}'[show help]' \
|
|
58
|
+
'(- *)--version[show version]' \
|
|
59
|
+
'(- *)--zsh-completion[print zsh completion setup instructions]' \
|
|
60
|
+
'--current[List of current entry tasks]:tasks:_standup_array_values' \
|
|
61
|
+
'--previous[List of previous entry tasks]:tasks:_standup_array_values' \
|
|
62
|
+
'--impediments[List of impediments for current entry]:impediments:_standup_array_values' \
|
|
63
|
+
'--notes[List of notes for current entry]:notes:_standup_array_values' \
|
|
64
|
+
'--sub-header-order[The order of the sub-headers when writing the file]:sub-header order:_standup_sub_header_order' \
|
|
65
|
+
'(-f --file-name-format)-f[Date-formattable string to use for standup file name]:strftime format:' \
|
|
66
|
+
'(-f --file-name-format)--file-name-format[Date-formattable string to use for standup file name]:strftime format:' \
|
|
67
|
+
'(-E --editor)-E[Editor to use for opening standup files]:editor:_path_commands' \
|
|
68
|
+
'(-E --editor)--editor[Editor to use for opening standup files]:editor:_path_commands' \
|
|
69
|
+
'(-d --directory)-d[The directory where standup files are located]:directory:_directories' \
|
|
70
|
+
'(-d --directory)--directory[The directory where standup files are located]:directory:_directories' \
|
|
71
|
+
'(-w --write --no-write)'{-w,--write}'[write current entry if it does not exist]' \
|
|
72
|
+
'(-w --write --no-write)--no-write[do not write current entry if it does not exist]' \
|
|
73
|
+
'(-a --auto-fill-previous --no-auto-fill-previous)'{-a,--auto-fill-previous}'[auto-generate previous tasks for new entries]' \
|
|
74
|
+
'(-a --auto-fill-previous --no-auto-fill-previous)--no-auto-fill-previous[do not auto-generate previous tasks for new entries]' \
|
|
75
|
+
'(-e --edit --no-edit)'{-e,--edit}'[open the file in the editor]' \
|
|
76
|
+
'(-e --edit --no-edit)--no-edit[do not open the file in the editor]' \
|
|
77
|
+
'(-v --verbose --no-verbose)'{-v,--verbose}'[use verbose output]' \
|
|
78
|
+
'(-v --verbose --no-verbose)--no-verbose[disable verbose output]' \
|
|
79
|
+
'(-p --print)'{-p,--print}'[print current entry]::date:_standup_dates' \
|
|
80
|
+
'1:standup file date:_standup_dates'
|
|
@@ -104,6 +104,11 @@ module StandupMD
|
|
|
104
104
|
"Verbose output. Default is false."
|
|
105
105
|
) { |v| config.cli.verbose = v }
|
|
106
106
|
|
|
107
|
+
opts.on(
|
|
108
|
+
"--zsh-completion",
|
|
109
|
+
"Print zsh completion setup instructions"
|
|
110
|
+
) { @zsh_completion_requested = true }
|
|
111
|
+
|
|
107
112
|
opts.on(
|
|
108
113
|
"-p", "--print [DATE]",
|
|
109
114
|
"Print current entry.",
|
|
@@ -115,6 +120,17 @@ module StandupMD
|
|
|
115
120
|
v.nil? ? Date.today : Date.strptime(v, config.file.header_date_format)
|
|
116
121
|
end
|
|
117
122
|
end.parse!(options)
|
|
123
|
+
if zsh_completion_requested?
|
|
124
|
+
raise OptionParser::InvalidArgument, options.join(" ") unless options.empty?
|
|
125
|
+
|
|
126
|
+
return
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
unless options.empty?
|
|
130
|
+
@file_date_argument = true
|
|
131
|
+
config.cli.date = parse_file_date(options.shift)
|
|
132
|
+
end
|
|
133
|
+
raise OptionParser::InvalidArgument, options.join(" ") unless options.empty?
|
|
118
134
|
end
|
|
119
135
|
|
|
120
136
|
##
|
|
@@ -123,7 +139,7 @@ module StandupMD
|
|
|
123
139
|
# @return [StandupMD::Entry]
|
|
124
140
|
def new_entry(file)
|
|
125
141
|
entry = file.entries.find(config.cli.date)
|
|
126
|
-
return entry
|
|
142
|
+
return entry if read_only? || entry || config.cli.date != Date.today
|
|
127
143
|
|
|
128
144
|
StandupMD::Entry.new(
|
|
129
145
|
config.cli.date,
|
|
@@ -145,6 +161,25 @@ module StandupMD
|
|
|
145
161
|
prev_entry(file.entries)
|
|
146
162
|
end
|
|
147
163
|
|
|
164
|
+
##
|
|
165
|
+
# Parses the optional file date argument.
|
|
166
|
+
#
|
|
167
|
+
# @param [String] value
|
|
168
|
+
#
|
|
169
|
+
# @return [Date]
|
|
170
|
+
def parse_file_date(value)
|
|
171
|
+
case value
|
|
172
|
+
when /\A\d{4}-\d{2}-\d{2}\z/
|
|
173
|
+
Date.strptime(value, "%Y-%m-%d")
|
|
174
|
+
when /\A\d{4}-\d{2}\z/
|
|
175
|
+
Date.strptime(value, "%Y-%m")
|
|
176
|
+
else
|
|
177
|
+
raise OptionParser::InvalidArgument, value
|
|
178
|
+
end
|
|
179
|
+
rescue ArgumentError
|
|
180
|
+
raise OptionParser::InvalidArgument, value
|
|
181
|
+
end
|
|
182
|
+
|
|
148
183
|
##
|
|
149
184
|
# The previous entry.
|
|
150
185
|
#
|
data/lib/standup_md/cli.rb
CHANGED
|
@@ -9,6 +9,10 @@ module StandupMD
|
|
|
9
9
|
class Cli
|
|
10
10
|
include Helpers
|
|
11
11
|
|
|
12
|
+
ZSH_COMPLETION_FILE = ::File.expand_path(
|
|
13
|
+
::File.join(__dir__, "..", "..", "completion", "zsh", "_standup")
|
|
14
|
+
).freeze
|
|
15
|
+
|
|
12
16
|
##
|
|
13
17
|
# Access to the class's configuration.
|
|
14
18
|
#
|
|
@@ -25,11 +29,46 @@ module StandupMD
|
|
|
25
29
|
puts msg if config.verbose
|
|
26
30
|
end
|
|
27
31
|
|
|
32
|
+
##
|
|
33
|
+
# Prints zsh completion setup instructions.
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
def self.zsh_completion_instructions
|
|
37
|
+
completion_dir = ::File.dirname(ZSH_COMPLETION_FILE)
|
|
38
|
+
|
|
39
|
+
<<~INSTRUCTIONS
|
|
40
|
+
Zsh completion file:
|
|
41
|
+
#{ZSH_COMPLETION_FILE}
|
|
42
|
+
|
|
43
|
+
To load it directly, add this before compinit runs:
|
|
44
|
+
|
|
45
|
+
fpath=("#{completion_dir}" $fpath)
|
|
46
|
+
autoload -Uz compinit
|
|
47
|
+
compinit
|
|
48
|
+
|
|
49
|
+
Or symlink it into your own completion directory:
|
|
50
|
+
|
|
51
|
+
mkdir -p ~/.zsh/completions
|
|
52
|
+
ln -sf "#{ZSH_COMPLETION_FILE}" ~/.zsh/completions/_standup
|
|
53
|
+
|
|
54
|
+
Then make sure that directory is in fpath before compinit runs:
|
|
55
|
+
|
|
56
|
+
fpath=(~/.zsh/completions $fpath)
|
|
57
|
+
autoload -Uz compinit
|
|
58
|
+
compinit
|
|
59
|
+
INSTRUCTIONS
|
|
60
|
+
end
|
|
61
|
+
|
|
28
62
|
##
|
|
29
63
|
# Creates an instance of +StandupMD+ and runs what the user requested.
|
|
30
64
|
def self.execute(options = [])
|
|
31
65
|
new(options).tap do |exe|
|
|
32
|
-
|
|
66
|
+
if exe.zsh_completion_requested?
|
|
67
|
+
puts zsh_completion_instructions
|
|
68
|
+
next
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
exe.write_file if exe.write?
|
|
33
72
|
if config.print
|
|
34
73
|
exe.print(exe.entry)
|
|
35
74
|
elsif config.edit
|
|
@@ -56,6 +95,22 @@ module StandupMD
|
|
|
56
95
|
# @return [StandupMD::File]
|
|
57
96
|
attr_reader :file
|
|
58
97
|
|
|
98
|
+
##
|
|
99
|
+
# Was a file date argument passed?
|
|
100
|
+
#
|
|
101
|
+
# @return [Boolean]
|
|
102
|
+
def file_date_argument?
|
|
103
|
+
@file_date_argument
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# Was zsh completion output requested?
|
|
108
|
+
#
|
|
109
|
+
# @return [Boolean]
|
|
110
|
+
def zsh_completion_requested?
|
|
111
|
+
@zsh_completion_requested
|
|
112
|
+
end
|
|
113
|
+
|
|
59
114
|
##
|
|
60
115
|
# Constructor. Sets defaults.
|
|
61
116
|
#
|
|
@@ -63,12 +118,18 @@ module StandupMD
|
|
|
63
118
|
def initialize(options = [], load_config: true)
|
|
64
119
|
@config = self.class.config
|
|
65
120
|
@preference_file_loaded = false
|
|
121
|
+
@file_date_argument = false
|
|
122
|
+
@zsh_completion_requested = false
|
|
66
123
|
@options = options
|
|
124
|
+
return if load_zsh_completion_request(options)
|
|
125
|
+
|
|
67
126
|
load_preferences if load_config
|
|
68
127
|
load_runtime_preferences(options)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@
|
|
128
|
+
return if zsh_completion_requested?
|
|
129
|
+
|
|
130
|
+
@file = find_file
|
|
131
|
+
@file&.load
|
|
132
|
+
@entry = @file.nil? ? nil : new_entry(@file)
|
|
72
133
|
end
|
|
73
134
|
|
|
74
135
|
##
|
|
@@ -110,6 +171,14 @@ module StandupMD
|
|
|
110
171
|
file.write
|
|
111
172
|
end
|
|
112
173
|
|
|
174
|
+
##
|
|
175
|
+
# Should the file be written?
|
|
176
|
+
#
|
|
177
|
+
# @return [Boolean]
|
|
178
|
+
def write?
|
|
179
|
+
!!(@config.write && !read_only? && entry)
|
|
180
|
+
end
|
|
181
|
+
|
|
113
182
|
##
|
|
114
183
|
# Quick access to +Cli.echo+.
|
|
115
184
|
#
|
|
@@ -117,5 +186,54 @@ module StandupMD
|
|
|
117
186
|
def echo(msg)
|
|
118
187
|
self.class.echo(msg)
|
|
119
188
|
end
|
|
189
|
+
|
|
190
|
+
private
|
|
191
|
+
|
|
192
|
+
##
|
|
193
|
+
# Detects zsh completion setup requests before loading user preferences.
|
|
194
|
+
#
|
|
195
|
+
# @return [Boolean]
|
|
196
|
+
def load_zsh_completion_request(options)
|
|
197
|
+
return false unless options.include?("--zsh-completion")
|
|
198
|
+
|
|
199
|
+
invalid_options = options - ["--zsh-completion"]
|
|
200
|
+
raise OptionParser::InvalidArgument, invalid_options.join(" ") unless invalid_options.empty?
|
|
201
|
+
|
|
202
|
+
@zsh_completion_requested = true
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
##
|
|
206
|
+
# Is this a read-only action?
|
|
207
|
+
#
|
|
208
|
+
# @return [Boolean]
|
|
209
|
+
def read_only?
|
|
210
|
+
@config.print || file_date_argument?
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
##
|
|
214
|
+
# Finds the file, avoiding file creation for read-only actions.
|
|
215
|
+
#
|
|
216
|
+
# @return [StandupMD::File, nil]
|
|
217
|
+
def find_file
|
|
218
|
+
return StandupMD::File.find_by_date(@config.date) unless read_only?
|
|
219
|
+
|
|
220
|
+
without_file_creation { StandupMD::File.find_by_date(@config.date) }
|
|
221
|
+
rescue
|
|
222
|
+
raise unless @config.print
|
|
223
|
+
|
|
224
|
+
nil
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
##
|
|
228
|
+
# Temporarily disables file creation while looking for a file.
|
|
229
|
+
#
|
|
230
|
+
# @return [StandupMD::File]
|
|
231
|
+
def without_file_creation
|
|
232
|
+
original_create = config.file.create
|
|
233
|
+
config.file.create = false
|
|
234
|
+
yield
|
|
235
|
+
ensure
|
|
236
|
+
config.file.create = original_create
|
|
237
|
+
end
|
|
120
238
|
end
|
|
121
239
|
end
|
data/lib/standup_md/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: standup_md
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Evan Gray
|
|
@@ -107,6 +107,7 @@ files:
|
|
|
107
107
|
- Rakefile
|
|
108
108
|
- _config.yml
|
|
109
109
|
- bin/standup
|
|
110
|
+
- completion/zsh/_standup
|
|
110
111
|
- lib/standup_md.rb
|
|
111
112
|
- lib/standup_md/cli.rb
|
|
112
113
|
- lib/standup_md/cli/helpers.rb
|