dsu 2.0.8 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -2
  3. data/Gemfile.lock +9 -9
  4. data/README.md +178 -69
  5. data/lib/core/ruby/color_theme_mode.rb +1 -1
  6. data/lib/dsu/base_cli.rb +3 -17
  7. data/lib/dsu/cli.rb +44 -72
  8. data/lib/dsu/command_services/add_entry_service.rb +1 -1
  9. data/lib/dsu/env.rb +4 -0
  10. data/lib/dsu/models/color_theme.rb +2 -2
  11. data/lib/dsu/models/configuration.rb +3 -1
  12. data/lib/dsu/models/entry_group.rb +1 -1
  13. data/lib/dsu/presenters/color_theme_presenter.rb +4 -2
  14. data/lib/dsu/presenters/color_theme_show_presenter.rb +9 -3
  15. data/lib/dsu/presenters/configuration_presenter.rb +2 -2
  16. data/lib/dsu/presenters/entry_group_presenter.rb +2 -2
  17. data/lib/dsu/services/entry_group/counter_service.rb +32 -0
  18. data/lib/dsu/services/entry_group/deleter_service.rb +35 -0
  19. data/lib/dsu/services/entry_group/editor_service.rb +7 -11
  20. data/lib/dsu/subcommands/base_subcommand.rb +0 -2
  21. data/lib/dsu/subcommands/config.rb +17 -74
  22. data/lib/dsu/subcommands/delete.rb +107 -0
  23. data/lib/dsu/subcommands/edit.rb +16 -30
  24. data/lib/dsu/subcommands/list.rb +26 -96
  25. data/lib/dsu/subcommands/theme.rb +50 -79
  26. data/lib/dsu/support/ask.rb +1 -1
  27. data/lib/dsu/support/command_help_colorizeable.rb +7 -0
  28. data/lib/dsu/support/command_hookable.rb +2 -0
  29. data/lib/dsu/support/command_options/dsu_times.rb +10 -10
  30. data/lib/dsu/support/command_options/time.rb +1 -0
  31. data/lib/dsu/support/command_options/time_mnemonic.rb +108 -0
  32. data/lib/dsu/support/command_options/{time_mneumonics.rb → time_mnemonics.rb} +2 -1
  33. data/lib/dsu/support/time_formatable.rb +13 -0
  34. data/lib/dsu/validators/description_validator.rb +2 -0
  35. data/lib/dsu/validators/entries_validator.rb +1 -0
  36. data/lib/dsu/version.rb +1 -1
  37. data/lib/dsu/views/color_theme/show.rb +1 -0
  38. data/lib/dsu/views/entry_group/edit.rb +2 -1
  39. data/lib/dsu/views/entry_group/shared/no_entries_to_display.rb +4 -1
  40. data/lib/dsu/views/shared/model_errors.rb +1 -0
  41. data/lib/dsu.rb +5 -1
  42. data/lib/locales/en/active_record.yml +8 -0
  43. data/lib/locales/en/commands.yml +136 -0
  44. data/lib/locales/en/miscellaneous.yml +23 -0
  45. data/lib/locales/en/presenters.yml +19 -0
  46. data/lib/locales/en/services.yml +10 -0
  47. data/lib/locales/en/subcommands.yml +348 -0
  48. metadata +26 -27
  49. data/exe/dsu_migrate.rb +0 -43
  50. data/lib/dsu/support/command_options/time_mneumonic.rb +0 -108
  51. data/lib/dsu/support/subcommand_help_colorizeable.rb +0 -27
@@ -0,0 +1,348 @@
1
+ # lib/dsu/subcommands
2
+ en:
3
+ subcommands:
4
+ config:
5
+ delete:
6
+ desc: delete
7
+ usage: Deletes the configuration file
8
+ long_desc: |
9
+ Deletes the configuration file.
10
+
11
+ EXAMPLES:
12
+
13
+ dsu config delete
14
+
15
+ NOTES
16
+
17
+ Deleting the dsu configuration file will simply cause dsu to use the default configuration options (`Dsu::Models::Configuration::DEFAULT_CONFIGURATION`).
18
+ info:
19
+ desc: info
20
+ usage: Displays information about this gem configuration
21
+ long_desc: |
22
+ Displays information about this gem configuration.
23
+
24
+ EXAMPLES:
25
+
26
+ $ dsu config info
27
+ init:
28
+ desc: init
29
+ usage: Creates and initializes a .dsu file in your home folder
30
+ long_desc: |
31
+ Creates and initializes a .dsu file in your home folder (%{home_folder}) that may be edited.
32
+
33
+ EXAMPLES:
34
+
35
+ $ dsu config init
36
+
37
+ CONFIGURATION FILE ENTRIES
38
+
39
+ The following configuration file options are available:
40
+
41
+ version:
42
+
43
+ The configuration version - DO NOT ALTER THIS VALUE!
44
+
45
+ editor:
46
+
47
+ The default editor to use when editing entry groups if the EDITOR environment variable on your system is not set. The default is 'nano'. You'll need to change the default editor on Windows systems.
48
+
49
+ Default: "nano" on nix sytems.
50
+
51
+ entries_display_order:
52
+
53
+ The order by which entries will be displayed, "asc" or "desc" (ascending or descending, respectively).
54
+
55
+ Default: "desc"
56
+
57
+ carry_over_entries_to_today:
58
+
59
+ Applicable to the `dsu edit` command. Valid values are true|false. If true, when editing DSU entries for the first time on any given day (e.g. `dsu edit today`), DSU entries from the previous day will be copied into the current editing session. If there are no DSU entries from the previous day, dsu will search backwards up to 7 days to find a DSU date that has entries to copy. If after searching back 7 days, no DSU entries are found, the editor session will simply provide no previous DSU entries.
60
+
61
+ Default: false
62
+
63
+ include_all:
64
+
65
+ Applicable to dsu commands that display DSU date lists (e.g. `dsu list` commands). Valid values are true|false. If true, all DSU dates within the specified range will be displayed, regardless of whether or not a particular date has entries. If false, only DSU dates between the first and last DSU dates that have entries will be displayed.
66
+
67
+ Default: false
68
+
69
+ theme_name:
70
+
71
+ Default: "default"
72
+ delete:
73
+ date:
74
+ desc: date|d DATE|MNEMONIC
75
+ usage: Deletes the DSU entries for the given DATE or MNEMONIC
76
+ long_desc: |
77
+ Deletes the DSU entries for the given DATE or MNEMONIC.
78
+
79
+ %{date_option_description}
80
+
81
+ %{mnemonic_option_description}
82
+ dates:
83
+ desc: dates|dd OPTIONS
84
+ usage: Deletes the DSU entries for the OPTIONS provided
85
+ long_desc: |
86
+ Deletes the DSU entries for the given OPTIONS.
87
+
88
+ $ dsu dates OPTIONS
89
+
90
+ $ dsu dd OPTIONS
91
+
92
+ OPTIONS:
93
+
94
+ -f|--from DATE|MNEMONIC: The DATE or MNEMONIC that represents the start of the range of DSU dates to delete. If a relative mnemonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the current date (e.g. `<MNEMONIC>.to_i.days.from_now(Time.now)`).
95
+
96
+ -t|--to DATE|MNEMONIC: The DATE or MNEMONIC that represents the end of the range of DSU dates to delete. If a relative mnemonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the date that resulting from the `--from` option date calculation.
97
+
98
+ %{date_option_description}
99
+
100
+ %{mnemonic_option_description}
101
+
102
+ EXAMPLES:
103
+
104
+ NOTE: All examples can substitute their respective short form options (e.g. `-f`, `-t`, etc. for `--from`, `--to`, etc.).
105
+
106
+ The below will delete the DSU entries for the range of dates from 1/1 to 1/4 for the current year:
107
+
108
+ $ dsu delete dates --from 1/1 --to +3
109
+
110
+ This will delete the DSU entries for the range of dates from 1/2 to 1/5 for the year 2022:
111
+
112
+ $ dsu delete dates --from 1/5/2022 --to -3
113
+
114
+ This (assuming "today" is 1/10) will delete the DSU entries for the last week 1/10 to 1/3 of the current year:
115
+
116
+ $ dsu delete dates --from today --to -7
117
+
118
+ This (assuming "today" is 5/23) will delete the DSU entries for the last week 5/16 to 5/22.
119
+ This example simply illustrates the fact that you can use relative mnemonics for
120
+ both `--from` and `--to` options; this doesn't mean you should do so...
121
+
122
+ While you can use relative mnemonics for both `--from` and `--to` options,
123
+ there is always a more intuitive way. The below example basically deletes one week of DSU entries back 1 week from yesterday's date:
124
+
125
+ $ dsu delete dates --from -7 --to +6
126
+
127
+ The above can be accomplished MUCH easier by simply using the `yesterday` mnemonic...
128
+
129
+ This (assuming "today" is 5/23) will delete the DSU entries back 1 week from yesterday's date 5/16 to 5/22:
130
+
131
+ $ dsu delete dates --from yesterday --to -6
132
+ today:
133
+ desc: today|n
134
+ usage: Deletes the DSU entries for today
135
+ long_desc: |
136
+ Deletes the DSU entries for today.
137
+
138
+ $ dsu delete today
139
+
140
+ $ dsu delete n
141
+ tomorrow:
142
+ desc: tomorrow|t
143
+ usage: Deletes the DSU entries for tomorrow
144
+ long_desc: |
145
+ Deletes the DSU entries for tomorrow.
146
+
147
+ $ dsu delete tomorrow
148
+
149
+ $ dsu delete t
150
+ yesterday:
151
+ desc: yesterday|y
152
+ usage: Deletes the DSU entries for yesterday
153
+ long_desc: |
154
+ Deletes the DSU entries for yesterday.
155
+
156
+ $ dsu delete yesterday
157
+
158
+ $ dsu delete y
159
+ messages:
160
+ deleted: Deleted %{count} entry group(s).
161
+ canceled: Canceled.
162
+ prompts:
163
+ are_you_sure: Are you sure you want to delete all the entries for %{dates} (%{count} entry groups)?
164
+ edit:
165
+ date:
166
+ desc: date|d DATE
167
+ usage: Edits the DSU entries for DATE
168
+ long_desc: |
169
+ Edits the DSU entries for DATE.
170
+
171
+ %{date_option_description}
172
+ today:
173
+ desc: today|n
174
+ usage: Edits the DSU entries for today
175
+ long_desc: |
176
+ Edits the DSU entries for today.
177
+ tomorrow:
178
+ desc: tomorrow|t
179
+ usage: Edits the DSU entries for tomorrow
180
+ long_desc: |
181
+ Edits the DSU entries for tomorrow.
182
+ yesterday:
183
+ desc: yesterday|y
184
+ usage: Edits the DSU entries for yesterday
185
+ long_desc: |
186
+ Edits the DSU entries for yesterday.
187
+ list:
188
+ date:
189
+ desc: date|d DATE|MNEMONIC
190
+ usage: Displays the DSU entries for the given DATE or MNEMONIC
191
+ long_desc: |
192
+ Displays the DSU entries for the given DATE or MNEMONIC.
193
+
194
+ %{date_option_description}
195
+
196
+ %{mnemonic_option_description}
197
+ dates:
198
+ desc: dates|dd OPTIONS
199
+ usage: Displays the DSU entries for the OPTIONS provided
200
+ long_desc: |
201
+ Displays the DSU entries for the given OPTIONS.
202
+
203
+ $ dsu dates OPTIONS
204
+
205
+ $ dsu dd OPTIONS
206
+
207
+ OPTIONS:
208
+
209
+ -a|--include-all true|false: If true, all DSU dates within the specified range will be displayed. If false, DSU dates between the first and last DSU dates that have NO entries will NOT be displayed.. The default is taken from the dsu configuration setting :include_all, see `dsu config info`.
210
+
211
+ -f|--from DATE|MNEMONIC: The DATE or MNEMONIC that represents the start of the range of DSU dates to display. If a relative mnemonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the current date (e.g. `<MNEMONIC>.to_i.days.from_now(Time.now)`).
212
+
213
+ -t|--to DATE|MNEMONIC: The DATE or MNEMONIC that represents the end of the range of DSU dates to display. If a relative mnemonic is used (+/-n, e.g +1, -1, etc.), the date calculated will be relative to the date that resulting from the `--from` option date calculation.
214
+
215
+ %{date_option_description}
216
+
217
+ %{mnemonic_option_description}
218
+
219
+ EXAMPLES:
220
+
221
+ NOTE: All example results are subject to the `--include-all|-a` option.
222
+
223
+ NOTE: All examples can substitute their respective short form options (e.g. `-f`, `-t`, etc. for `--from`, `--to`, etc.).
224
+
225
+ The below will display the DSU entries for the range of dates from 1/1 to 1/4 for the current year:
226
+
227
+ $ dsu list dates --from 1/1 --to +3
228
+
229
+ This will display the DSU entries for the range of dates from 1/2 to 1/5 for the year 2022:
230
+
231
+ $ dsu list dates --from 1/5/2022 --to -3
232
+
233
+ This (assuming "today" is 1/10) will display the DSU entries for the last week 1/10 to 1/3 of the current year:
234
+
235
+ $ dsu list dates --from today --to -7
236
+
237
+ This (assuming "today" is 5/23) will display the DSU entries for the last week 5/16 to 5/22.
238
+ This example simply illustrates the fact that you can use relative mnemonics for
239
+ both `--from` and `--to` options; this doesn't mean you should do so...
240
+
241
+ While you can use relative mnemonics for both `--from` and `--to` options,
242
+ there is always a more intuitive way. The below example basically lists one week
243
+ of DSU entries back 1 week from yesterday's date:
244
+
245
+ $ dsu list dates --from -7 --to +6
246
+
247
+ The above can be accomplished MUCH easier by simply using the `yesterday` mnemonic...
248
+
249
+ This (assuming "today" is 5/23) will display the DSU entries back 1 week from yesterday's date 5/16 to 5/22:
250
+
251
+ $ dsu list dates --from yesterday --to -6
252
+ today:
253
+ desc: today|n
254
+ usage: Displays the DSU entries for today
255
+ long_desc: |
256
+ Displays the DSU entries for today.
257
+
258
+ $ dsu list today
259
+
260
+ $ dsu list n
261
+ tomorrow:
262
+ desc: tomorrow|t
263
+ usage: Displays the DSU entries for tomorrow
264
+ long_desc: |
265
+ Displays the DSU entries for tomorrow.
266
+
267
+ $ dsu list tomorrow
268
+
269
+ $ dsu list t
270
+ yesterday:
271
+ desc: yesterday|y
272
+ usage: Displays the DSU entries for yesterday
273
+ long_desc: |
274
+ Displays the DSU entries for yesterday.
275
+
276
+ $ dsu list yesterday
277
+
278
+ $ dsu list y
279
+ theme:
280
+ create:
281
+ desc: create THEME_NAME [OPTIONS]
282
+ usage: Creates a dsu color theme named THEME_NAME
283
+ long_desc: |
284
+ Creates a dsu color theme named THEME_NAME in the %{themes_folder} folder.
285
+
286
+ $ dsu create THEME_NAME [-d|--description DESCRIPTION]
287
+
288
+ OPTIONS:
289
+
290
+ -d|--description DESCRIPTION: Creates the dsu color theme with having DESCRIPTION as the color theme description.
291
+
292
+ DESCRIPTION
293
+
294
+ Must be be between 2 and 256 characters (inclusive) in length.
295
+ prompts:
296
+ create_theme: Create color theme "%{theme_name}"?
297
+ errors:
298
+ already_exists: Color theme "%{theme_name}" already exists.
299
+ messages:
300
+ created: Created color theme "%{theme_name}".
301
+ canceled: Canceled.
302
+ delete:
303
+ desc: delete THEME_NAME
304
+ usage: Deletes the existing dsu color theme THEME_NAME
305
+ long_desc: |
306
+ Deletes the existing dsu color theme THEME_NAME in the %{themes_folder} folder.
307
+
308
+ $ dsu theme delete THEME_NAME
309
+ prompts:
310
+ delete_theme: Delete color theme "%{theme_name}"?
311
+ errors:
312
+ cannot_delete: Color theme "%{theme_name}" cannot be deleted.
313
+ messages:
314
+ canceled: Canceled.
315
+ deleted: Deleted color theme "%{theme_name}".
316
+ list:
317
+ desc: list
318
+ usage: Lists the available dsu color themes.
319
+ long_desc: |
320
+ Lists the available dsu color themes in the %{themes_folder} folder.
321
+
322
+ $ dsu theme list
323
+ use:
324
+ desc: use [THEME_NAME]
325
+ usage: Sets the dsu color theme to THEME_NAME
326
+ long_desc: |
327
+ Sets the dsu color theme to THEME_NAME.
328
+
329
+ $ dsu theme use [THEME_NAME]
330
+
331
+ NOTES
332
+
333
+ If THEME_NAME is not provided, the default theme will be used.
334
+
335
+ If THEME_NAME does not exist, you will be given the option to create a new theme.
336
+ messages:
337
+ using_color_theme: Using color theme "%{theme_name}".
338
+ show:
339
+ desc: show THEME_NAME
340
+ usage: Displays the dsu color theme THEME_NAME
341
+ long_desc: |
342
+ Displays the dsu color theme THEME_NAME.
343
+
344
+ $ dsu theme show THEME_NAME
345
+ generic:
346
+ color_theme: "%{theme_name} color theme"
347
+ errors:
348
+ does_not_exist: Color theme "%{theme_name}" does not exist.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-02 00:00:00.000000000 Z
11
+ date: 2023-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -130,30 +130,18 @@ dependencies:
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '2.0'
133
- description: ' dsu is a small, but powerful gem that helps manage your Agile DSU
134
- (Daily Stand Up) participation. How? by providing a simple command-line interface
135
- (CLI) which allows you to create, read, update, and delete (CRUD) your DSU entries
136
- (activities). During your DSU, you can use dsu''s CLI to list and share what you
137
- did "yesterday" and what you plan on doing "Today" with your team. DSU entries are
138
- grouped by day and can be viewed in simple text format from the command-line. When
139
- displaying DSU entries for a particular day, dsu will also display DSU entries for
140
- the previous day. If the day you are trying to display falls on a weekend or Monday,
141
- dsu will automatically search back to include the weekend and previous Friday dates
142
- and display the entries; this is so that you can share what you did over the weekend
143
- (if anything) and the previous Friday with your team. When searching for "Yesterday''s"
144
- DSU entries, dsu will automatically search back a maximimum of 7 days to find DSU
145
- entries to share. This could be helpful if, for example, if you are sharing what
146
- you plan to do today (Wednesday), but were sick yesterday (Tuesday); dsu in this
147
- case will display the last DSU entries it can find searching backwards a maximum
148
- of 7 days. dsu does a LOT more and is perfect for command-line junkies and those
149
- who LOVE simplicity. Give it a try and a star if you like it!
150
-
151
- '
133
+ description: " Get ready to jazz and snazz up your daily stand-ups with dsu, the
134
+ agile developer's new best friend! This handy command-line gem is all about making
135
+ your Daily Stand-Up (DSU) participation smooth, fun, and super efficient. Effortlessly
136
+ create, update, and organize your DSU entries, turning the task of tracking and
137
+ sharing your daily activities into a breeze. With its intuitive interface and smart
138
+ date management, dsu ensures you’re always ready to inform your team about your
139
+ recent progress and upcoming plans. Perfect for command-line tool enthusiasts, dsu
140
+ brings a dash of simplicity and fun, fun, fun to your daily agile routine!\n"
152
141
  email:
153
142
  - public.gma@gmail.com
154
143
  executables:
155
144
  - dsu
156
- - dsu_migrate.rb
157
145
  extensions: []
158
146
  extra_rdoc_files: []
159
147
  files:
@@ -172,7 +160,6 @@ files:
172
160
  - bin/dsu
173
161
  - bin/setup
174
162
  - exe/dsu
175
- - exe/dsu_migrate.rb
176
163
  - lib/core/ruby/color_theme_colors.rb
177
164
  - lib/core/ruby/color_theme_mode.rb
178
165
  - lib/core/ruby/wrap_and_join.rb
@@ -199,6 +186,8 @@ files:
199
186
  - lib/dsu/services/color_theme/hydrator_service.rb
200
187
  - lib/dsu/services/configuration/hydrator_service.rb
201
188
  - lib/dsu/services/entry/hydrator_service.rb
189
+ - lib/dsu/services/entry_group/counter_service.rb
190
+ - lib/dsu/services/entry_group/deleter_service.rb
202
191
  - lib/dsu/services/entry_group/editor_service.rb
203
192
  - lib/dsu/services/entry_group/hydrator_service.rb
204
193
  - lib/dsu/services/migration_version/hydrator_service.rb
@@ -208,6 +197,7 @@ files:
208
197
  - lib/dsu/services/temp_file/writer_service.rb
209
198
  - lib/dsu/subcommands/base_subcommand.rb
210
199
  - lib/dsu/subcommands/config.rb
200
+ - lib/dsu/subcommands/delete.rb
211
201
  - lib/dsu/subcommands/edit.rb
212
202
  - lib/dsu/subcommands/list.rb
213
203
  - lib/dsu/subcommands/theme.rb
@@ -217,14 +207,13 @@ files:
217
207
  - lib/dsu/support/command_hookable.rb
218
208
  - lib/dsu/support/command_options/dsu_times.rb
219
209
  - lib/dsu/support/command_options/time.rb
220
- - lib/dsu/support/command_options/time_mneumonic.rb
221
- - lib/dsu/support/command_options/time_mneumonics.rb
210
+ - lib/dsu/support/command_options/time_mnemonic.rb
211
+ - lib/dsu/support/command_options/time_mnemonics.rb
222
212
  - lib/dsu/support/descriptable.rb
223
213
  - lib/dsu/support/entry_group_viewable.rb
224
214
  - lib/dsu/support/field_errors.rb
225
215
  - lib/dsu/support/fileable.rb
226
216
  - lib/dsu/support/presentable.rb
227
- - lib/dsu/support/subcommand_help_colorizeable.rb
228
217
  - lib/dsu/support/time_comparable.rb
229
218
  - lib/dsu/support/time_formatable.rb
230
219
  - lib/dsu/support/times_sortable.rb
@@ -247,6 +236,12 @@ files:
247
236
  - lib/dsu/views/shared/model_errors.rb
248
237
  - lib/dsu/views/shared/success.rb
249
238
  - lib/dsu/views/shared/warning.rb
239
+ - lib/locales/en/active_record.yml
240
+ - lib/locales/en/commands.yml
241
+ - lib/locales/en/miscellaneous.yml
242
+ - lib/locales/en/presenters.yml
243
+ - lib/locales/en/services.yml
244
+ - lib/locales/en/subcommands.yml
250
245
  - lib/seed_data/themes/cherry.json
251
246
  - lib/seed_data/themes/default.json
252
247
  - lib/seed_data/themes/lemon.json
@@ -269,7 +264,11 @@ post_install_message: |
269
264
  View the dsu README.md here: https://github.com/gangelo/dsu
270
265
  View the dsu CHANGELOG.md: https://github.com/gangelo/dsu/blob/main/CHANGELOG.md
271
266
 
272
- Try a dsu theme by running `dsu theme list` and then `dsu theme use THEME_NAME` where THEME_NAME is the name of the theme you want to try :)
267
+ Dsu now has a delete command! Try it out by running `dsu delete help`.
268
+
269
+ Try a dsu theme by running `dsu theme list` and then `dsu theme use THEME_NAME` where THEME_NAME is the name of the theme you want to try.
270
+
271
+ :)
273
272
  rdoc_options: []
274
273
  require_paths:
275
274
  - lib
data/exe/dsu_migrate.rb DELETED
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # frozen_string_literal: true
4
-
5
- require 'bundler/setup'
6
- # require 'highline'
7
- require 'dsu'
8
-
9
- # def run_migrations?
10
- # puts '***********************************************'
11
- # puts '*** Migrations are pending! ***'
12
- # puts '*** This is a pre-release version of dsu. ***'
13
- # puts '*** It is highly recommended you exit ***'
14
- # puts '*** this installation! ***'
15
- # puts '***********************************************'
16
- # prompt = 'What do you want to do?' \
17
- # "\n c = Continue (install and run migrations)." \
18
- # "\n x = Exit (recommended)." \
19
- # "\n> "
20
- # input = HighLine.new.ask(prompt, String) do |question|
21
- # question.default = 'x'
22
- # question.readline = true
23
- # question.in = %w[x c]
24
- # end
25
- # input == 'c'
26
- # end
27
-
28
- def run_migrations!
29
- # return 1 unless run_migrations?
30
-
31
- puts 'Running migrations...'
32
- Dsu::Migration::Service.run_migrations!
33
- 0
34
- rescue StandardError => e
35
- puts "Error running migrations: #{e.message}"
36
- 1
37
- end
38
-
39
- if Dsu::Migration::Service.run_migrations?
40
- exit run_migrations!
41
- else
42
- exit 0
43
- end
@@ -1,108 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'time_mneumonics'
4
-
5
- module Dsu
6
- module Support
7
- module CommandOptions
8
- # The purpose of this module is to take a command option that is a string and return a Time object.
9
- # The command option is expected to be a time mneumoic.
10
- module TimeMneumonic
11
- include TimeMneumonics
12
-
13
- module_function
14
-
15
- def time_from_mneumonic(command_option:, relative_time: nil)
16
- time_from_mneumonic!(command_option: command_option, relative_time: relative_time)
17
- rescue ArgumentError
18
- nil
19
- end
20
-
21
- # command_option: is expected to me a time mneumonic. If relative_time is NOT nil, all
22
- # time mneumonics are relative to relative_time. Otherwise, they are relative to Time.now.
23
- # relative_time: is a Time object that is required IF command_option is expected to be
24
- # a relative time mneumonic. Otherwise, it is optional.
25
- def time_from_mneumonic!(command_option:, relative_time: nil)
26
- validate_argument!(command_option: command_option, command_option_name: :command_option)
27
- unless relative_time.nil? || relative_time.is_a?(::Time)
28
- raise ArgumentError, "relative_time is not a Time object: \"#{relative_time}\""
29
- end
30
-
31
- relative_time ||= ::Time.now
32
-
33
- time_for_mneumonic(mneumonic: command_option, relative_time: relative_time)
34
- end
35
-
36
- # This method returns true if mneumonic is a valid mneumonic OR
37
- # a relative time mneumonic.
38
- def time_mneumonic?(mneumonic)
39
- mneumonic?(mneumonic) || relative_time_mneumonic?(mneumonic)
40
- end
41
-
42
- # This method returns true if mneumonic is a valid relative
43
- # time mneumonic.
44
- def relative_time_mneumonic?(mneumonic)
45
- return false unless mneumonic.is_a?(String)
46
-
47
- mneumonic.match?(RELATIVE_REGEX)
48
- end
49
-
50
- # Add private_class_methods here.
51
-
52
- # Returns a Time object from a mneumonic.
53
- def time_for_mneumonic(mneumonic:, relative_time:)
54
- time = relative_time
55
- if today_mneumonic?(mneumonic)
56
- time
57
- elsif tomorrow_mneumonic?(mneumonic)
58
- time.tomorrow
59
- elsif yesterday_mneumonic?(mneumonic)
60
- time.yesterday
61
- elsif relative_time_mneumonic?(mneumonic)
62
- relative_time_for(days_from_now: mneumonic, time: time)
63
- end
64
- end
65
-
66
- def relative_time_for(days_from_now:, time:)
67
- days_from_now.to_i.days.from_now(time)
68
- end
69
-
70
- # This method returns true if mneumonic is a valid time mneumonic.
71
- # This method will return false if mneumonic is an invalid mneumonic
72
- # OR if mneumonic is a relative time mneumonic.
73
- def mneumonic?(mneumonic)
74
- today_mneumonic?(mneumonic) ||
75
- tomorrow_mneumonic?(mneumonic) ||
76
- yesterday_mneumonic?(mneumonic)
77
- end
78
-
79
- def today_mneumonic?(mneumonic)
80
- TODAY.include?(mneumonic)
81
- end
82
-
83
- def tomorrow_mneumonic?(mneumonic)
84
- TOMORROW.include?(mneumonic)
85
- end
86
-
87
- def yesterday_mneumonic?(mneumonic)
88
- YESERDAY.include?(mneumonic)
89
- end
90
-
91
- def validate_argument!(command_option:, command_option_name:)
92
- raise ArgumentError, "#{command_option_name} cannot be nil." if command_option.nil?
93
- raise ArgumentError, "#{command_option_name} cannot be blank." if command_option.blank?
94
- unless command_option.is_a?(String)
95
- raise ArgumentError, "#{command_option_name} must be a String: \"#{command_option}\""
96
- end
97
- unless time_mneumonic?(command_option)
98
- raise ArgumentError, "#{command_option_name} is an invalid mneumonic: \"#{command_option}\"."
99
- end
100
- end
101
-
102
- private_class_method :time_for_mneumonic, :relative_time_for,
103
- :mneumonic?, :today_mneumonic?, :tomorrow_mneumonic?,
104
- :yesterday_mneumonic?, :validate_argument!
105
- end
106
- end
107
- end
108
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../models/color_theme'
4
- require_relative '../support/color_themable'
5
-
6
- module Dsu
7
- module Support
8
- module SubcommandHelpColorizable
9
- class << self
10
- def included(base)
11
- base.extend(ClassMethods)
12
- end
13
-
14
- module ClassMethods
15
- def command_help(shell, subcommand = false) # rubocop:disable Style/OptionalBooleanParameter
16
- help_text = Services::StdoutRedirectorService.call { super }
17
- puts apply_theme(help_text, theme_color: color_theme.help)
18
- end
19
-
20
- def color_theme
21
- @color_theme ||= Models::ColorTheme.current_or_default
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end