doing 2.1.89 → 2.1.90
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/.irbrc +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +251 -0
- data/CHANGELOG.md +22 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -3
- data/bin/commands/changes.rb +3 -1
- data/bin/commands/choose.rb +2 -0
- data/bin/commands/colors.rb +5 -3
- data/bin/commands/commands_accepting.rb +3 -3
- data/bin/commands/completion.rb +2 -1
- data/bin/commands/config.rb +8 -6
- data/bin/commands/done.rb +19 -12
- data/bin/commands/finish.rb +4 -2
- data/bin/commands/grep.rb +9 -5
- data/bin/commands/import.rb +14 -11
- data/bin/commands/install_fzf.rb +4 -2
- data/bin/commands/last.rb +31 -27
- data/bin/commands/meanwhile.rb +6 -2
- data/bin/commands/note.rb +6 -3
- data/bin/commands/now.rb +2 -0
- data/bin/commands/open.rb +6 -1
- data/bin/commands/plugins.rb +2 -0
- data/bin/commands/recent.rb +47 -33
- data/bin/commands/reset.rb +7 -3
- data/bin/commands/rotate.rb +6 -3
- data/bin/commands/sections.rb +3 -3
- data/bin/commands/select.rb +2 -0
- data/bin/commands/show.rb +24 -20
- data/bin/commands/since.rb +10 -3
- data/bin/commands/tag.rb +18 -16
- data/bin/commands/tag_dir.rb +5 -2
- data/bin/commands/tags.rb +17 -17
- data/bin/commands/template.rb +8 -2
- data/bin/commands/today.rb +10 -2
- data/bin/commands/undo.rb +2 -0
- data/bin/commands/update.rb +9 -7
- data/bin/commands/view.rb +11 -8
- data/bin/commands/views.rb +2 -0
- data/bin/commands/yesterday.rb +6 -1
- data/bin/doing +54 -57
- data/docs/doc/Array.html +3 -3
- data/docs/doc/BooleanTermParser/Clause.html +3 -3
- data/docs/doc/BooleanTermParser/Operator.html +3 -3
- data/docs/doc/BooleanTermParser/Query.html +3 -3
- data/docs/doc/BooleanTermParser/QueryParser.html +3 -3
- data/docs/doc/BooleanTermParser/QueryTransformer.html +3 -3
- data/docs/doc/BooleanTermParser.html +3 -3
- data/docs/doc/Doing/ArrayCleanup.html +3 -3
- data/docs/doc/Doing/ArrayNestedHash.html +3 -3
- data/docs/doc/Doing/ArrayTags.html +9 -9
- data/docs/doc/Doing/ByDayExport.html +3 -3
- data/docs/doc/Doing/CSVExport.html +4 -4
- data/docs/doc/Doing/CalendarImport.html +4 -4
- data/docs/doc/Doing/Change.html +3 -3
- data/docs/doc/Doing/Changes.html +3 -3
- data/docs/doc/Doing/ChronifyArray.html +3 -3
- data/docs/doc/Doing/ChronifyNumeric.html +3 -3
- data/docs/doc/Doing/ChronifyString.html +6 -6
- data/docs/doc/Doing/Color.html +88 -47
- data/docs/doc/Doing/Completion/BashCompletions.html +3 -3
- data/docs/doc/Doing/Completion/FigCompletions.html +3 -3
- data/docs/doc/Doing/Completion/FishCompletions.html +3 -3
- data/docs/doc/Doing/Completion/StringUtils.html +3 -3
- data/docs/doc/Doing/Completion/ZshCompletions.html +3 -3
- data/docs/doc/Doing/Completion.html +5 -5
- data/docs/doc/Doing/Configuration.html +6 -6
- data/docs/doc/Doing/DayOneRenderer.html +3 -3
- data/docs/doc/Doing/DayoneExport.html +4 -4
- data/docs/doc/Doing/DoingExport.html +5 -5
- data/docs/doc/Doing/DoingImport.html +4 -4
- data/docs/doc/Doing/Entry.html +3 -3
- data/docs/doc/Doing/Errors/DoingNoTraceError.html +3 -3
- data/docs/doc/Doing/Errors/DoingRuntimeError.html +3 -3
- data/docs/doc/Doing/Errors/DoingStandardError.html +3 -3
- data/docs/doc/Doing/Errors/EmptyInput.html +3 -3
- data/docs/doc/Doing/Errors/HistoryLimitError.html +3 -3
- data/docs/doc/Doing/Errors/InvalidPlugin.html +3 -3
- data/docs/doc/Doing/Errors/MissingBackupFile.html +3 -3
- data/docs/doc/Doing/Errors/NoResults.html +3 -3
- data/docs/doc/Doing/Errors/PluginException.html +3 -3
- data/docs/doc/Doing/Errors/UserCancelled.html +3 -3
- data/docs/doc/Doing/Errors/WrongCommand.html +3 -3
- data/docs/doc/Doing/Errors.html +3 -3
- data/docs/doc/Doing/HTMLExport.html +4 -4
- data/docs/doc/Doing/Hooks.html +3 -16
- data/docs/doc/Doing/Item.html +4 -4
- data/docs/doc/Doing/ItemDates.html +3 -3
- data/docs/doc/Doing/ItemQuery.html +3 -3
- data/docs/doc/Doing/ItemState.html +3 -3
- data/docs/doc/Doing/ItemTags.html +3 -3
- data/docs/doc/Doing/Items.html +3 -3
- data/docs/doc/Doing/JSONExport.html +4 -4
- data/docs/doc/Doing/JSONImport.html +4 -4
- data/docs/doc/Doing/Logger.html +183 -3
- data/docs/doc/Doing/MarkdownExport.html +4 -4
- data/docs/doc/Doing/Note.html +3 -3
- data/docs/doc/Doing/Pager.html +54 -58
- data/docs/doc/Doing/Plugins.html +3 -3
- data/docs/doc/Doing/Prompt.html +4 -4
- data/docs/doc/Doing/PromptChoose.html +3 -3
- data/docs/doc/Doing/PromptFZF.html +3 -3
- data/docs/doc/Doing/PromptInput.html +3 -3
- data/docs/doc/Doing/PromptSTD.html +3 -3
- data/docs/doc/Doing/PromptYN.html +3 -3
- data/docs/doc/Doing/Section.html +3 -3
- data/docs/doc/Doing/StringHighlight.html +3 -3
- data/docs/doc/Doing/StringNormalize.html +3 -3
- data/docs/doc/Doing/StringQuery.html +4 -4
- data/docs/doc/Doing/StringTags.html +3 -3
- data/docs/doc/Doing/StringTransform.html +3 -3
- data/docs/doc/Doing/StringTruncate.html +3 -3
- data/docs/doc/Doing/StringURL.html +3 -3
- data/docs/doc/Doing/SymbolNormalize.html +5 -5
- data/docs/doc/Doing/TaskPaperExport.html +4 -4
- data/docs/doc/Doing/TemplateExport.html +5 -5
- data/docs/doc/Doing/TemplateString.html +7 -7
- data/docs/doc/Doing/TimingImport.html +4 -4
- data/docs/doc/Doing/Types.html +3 -3
- data/docs/doc/Doing/Util/Backup.html +4 -17
- data/docs/doc/Doing/Util.html +56 -61
- data/docs/doc/Doing/Version.html +3 -3
- data/docs/doc/Doing/WWID.html +6 -4
- data/docs/doc/Doing.html +4 -4
- data/docs/doc/FalseClass.html +3 -3
- data/docs/doc/GLI/Commands/Help.html +5 -5
- data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +3 -3
- data/docs/doc/GLI/Commands.html +3 -3
- data/docs/doc/GLI.html +3 -3
- data/docs/doc/Hash.html +4 -4
- data/docs/doc/Numeric.html +3 -3
- data/docs/doc/Object.html +3 -3
- data/docs/doc/PhraseParser/Operator.html +3 -3
- data/docs/doc/PhraseParser/PhraseClause.html +3 -3
- data/docs/doc/PhraseParser/Query.html +3 -3
- data/docs/doc/PhraseParser/QueryParser.html +3 -3
- data/docs/doc/PhraseParser/QueryTransformer.html +3 -3
- data/docs/doc/PhraseParser/TermClause.html +3 -3
- data/docs/doc/PhraseParser.html +3 -3
- data/docs/doc/Status.html +3 -3
- data/docs/doc/String.html +51 -5
- data/docs/doc/Symbol.html +3 -3
- data/docs/doc/Time.html +3 -3
- data/docs/doc/TrueClass.html +3 -3
- data/docs/doc/_index.html +4 -4
- data/docs/doc/class_list.html +6 -3
- data/docs/doc/css/full_list.css +3 -3
- data/docs/doc/css/style.css +6 -0
- data/docs/doc/file.README.html +3 -3
- data/docs/doc/file_list.html +5 -2
- data/docs/doc/frames.html +1 -1
- data/docs/doc/index.html +3 -3
- data/docs/doc/js/app.js +294 -264
- data/docs/doc/js/full_list.js +30 -4
- data/docs/doc/method_list.html +443 -392
- data/docs/doc/top-level-namespace.html +3 -3
- data/doing.gemspec +2 -0
- data/doing.rdoc +1 -1
- data/example_plugin.rb +1 -4
- data/lib/doing/add_options.rb +2 -2
- data/lib/doing/array/cleanup.rb +2 -0
- data/lib/doing/array/nested_hash.rb +2 -0
- data/lib/doing/boolean_term_parser.rb +3 -3
- data/lib/doing/changelog/changes.rb +4 -5
- data/lib/doing/changelog/version.rb +8 -11
- data/lib/doing/chronify/array.rb +4 -4
- data/lib/doing/chronify/string.rb +5 -4
- data/lib/doing/cli_status.rb +7 -2
- data/lib/doing/colors.rb +93 -51
- data/lib/doing/completion/bash_completion.rb +36 -39
- data/lib/doing/completion/completion_string.rb +2 -1
- data/lib/doing/completion/fig_completion.rb +33 -33
- data/lib/doing/completion/fish_completion.rb +22 -23
- data/lib/doing/completion/zsh_completion.rb +5 -5
- data/lib/doing/completion.rb +7 -4
- data/lib/doing/configuration.rb +21 -13
- data/lib/doing/errors.rb +1 -4
- data/lib/doing/good.rb +1 -1
- data/lib/doing/hash.rb +4 -4
- data/lib/doing/help_monkey_patch.rb +1 -1
- data/lib/doing/hooks.rb +6 -2
- data/lib/doing/item/dates.rb +3 -1
- data/lib/doing/item/query.rb +10 -10
- data/lib/doing/item/state.rb +2 -0
- data/lib/doing/logger.rb +113 -45
- data/lib/doing/markdown_document_listener.rb +25 -25
- data/lib/doing/normalize.rb +1 -1
- data/lib/doing/pager.rb +73 -29
- data/lib/doing/plugin_manager.rb +4 -5
- data/lib/doing/plugins/export/byday.rb +1 -1
- data/lib/doing/plugins/export/dayone_export.rb +28 -27
- data/lib/doing/plugins/export/doing_export.rb +1 -1
- data/lib/doing/plugins/export/html_export.rb +3 -3
- data/lib/doing/plugins/export/json_export.rb +4 -5
- data/lib/doing/plugins/export/markdown_export.rb +10 -2
- data/lib/doing/plugins/export/taskpaper_export.rb +1 -0
- data/lib/doing/plugins/export/template_export.rb +110 -107
- data/lib/doing/plugins/import/calendar_import.rb +1 -1
- data/lib/doing/plugins/import/doing_import.rb +2 -2
- data/lib/doing/plugins/import/timing_import.rb +3 -3
- data/lib/doing/prompt/choose.rb +5 -6
- data/lib/doing/prompt/fzf.rb +3 -2
- data/lib/doing/prompt/input.rb +7 -6
- data/lib/doing/prompt/yn.rb +9 -11
- data/lib/doing/string/tags.rb +7 -4
- data/lib/doing/string/transform.rb +15 -10
- data/lib/doing/string/truncate.rb +1 -0
- data/lib/doing/string/url.rb +1 -1
- data/lib/doing/template_string.rb +13 -9
- data/lib/doing/time.rb +4 -2
- data/lib/doing/util.rb +12 -11
- data/lib/doing/util_backup.rb +29 -26
- data/lib/doing/version.rb +3 -1
- data/lib/doing/wwid/display.rb +182 -151
- data/lib/doing/wwid/editor.rb +13 -12
- data/lib/doing/wwid/filetools.rb +13 -11
- data/lib/doing/wwid/filter.rb +41 -40
- data/lib/doing/wwid/guess.rb +6 -8
- data/lib/doing/wwid/interactive.rb +9 -9
- data/lib/doing/wwid/modify.rb +53 -53
- data/lib/doing/wwid/timers.rb +4 -5
- data/lib/doing/wwid/wwid.rb +0 -0
- data/lib/doing/wwid/wwidutil.rb +8 -10
- data/lib/examples/commands/wiki.rb +2 -0
- data/lib/examples/plugins/capture_thing_import.rb +1 -1
- data/lib/examples/plugins/say_export.rb +1 -2
- data/lib/examples/plugins/wiki_export/wiki_export.rb +3 -4
- data/lib/helpers/fzf/test/test_go.rb +5 -5
- data/lib/helpers/threaded_tests.rb +20 -20
- data/lib/helpers/threaded_tests_string.rb +2 -0
- data/rdoc_to_mmd.rb +5 -4
- data/rdocfixer.rb +1 -2
- data/scripts/deploy.rb +3 -4
- data/scripts/generate_bash_completions.rb +40 -43
- data/scripts/generate_fish_completions.rb +17 -15
- data/scripts/generate_zsh_completions.rb +9 -7
- data/scripts/setting_replace.rb +1 -0
- data/scripts/sort_commands.rb +4 -2
- data/yard_templates/default/method_details/setup.rb +3 -1
- metadata +3 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>
|
|
7
7
|
Top Level Namespace
|
|
8
8
|
|
|
9
|
-
— Documentation by YARD 0.9.
|
|
9
|
+
— Documentation by YARD 0.9.37
|
|
10
10
|
|
|
11
11
|
</title>
|
|
12
12
|
|
|
@@ -216,9 +216,9 @@
|
|
|
216
216
|
</div>
|
|
217
217
|
|
|
218
218
|
<div id="footer">
|
|
219
|
-
Generated on
|
|
219
|
+
Generated on Thu Oct 23 08:05:56 2025 by
|
|
220
220
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
221
|
-
0.9.
|
|
221
|
+
0.9.37 (ruby-3.4.4).
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
</div>
|
data/doing.gemspec
CHANGED
data/doing.rdoc
CHANGED
|
@@ -5,7 +5,7 @@ record of what you've been doing, complete with tag-based time tracking. The
|
|
|
5
5
|
command line tool allows you to add entries, annotate with tags and notes, and
|
|
6
6
|
view your entries with myriad options, with a focus on a "natural" language syntax.
|
|
7
7
|
|
|
8
|
-
v2.1.
|
|
8
|
+
v2.1.90
|
|
9
9
|
|
|
10
10
|
=== Global Options
|
|
11
11
|
=== --config_file arg
|
data/example_plugin.rb
CHANGED
|
@@ -83,7 +83,6 @@ module Doing
|
|
|
83
83
|
}
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
|
|
87
86
|
#-------------------------------------------------------
|
|
88
87
|
## Output a template. Only required if template(s) are
|
|
89
88
|
## included in settings. The method should return a
|
|
@@ -106,7 +105,6 @@ module Doing
|
|
|
106
105
|
'On %date, you were %title, recorded in section %section%took'
|
|
107
106
|
end
|
|
108
107
|
|
|
109
|
-
|
|
110
108
|
##
|
|
111
109
|
## Render data received from an output
|
|
112
110
|
## command
|
|
@@ -122,7 +120,7 @@ module Doing
|
|
|
122
120
|
##
|
|
123
121
|
## @return [String] Rendered output
|
|
124
122
|
##
|
|
125
|
-
def self.render(
|
|
123
|
+
def self.render(_wwid, items, variables: {})
|
|
126
124
|
return unless items.good?
|
|
127
125
|
|
|
128
126
|
config = Doing.config.settings
|
|
@@ -154,7 +152,6 @@ module Doing
|
|
|
154
152
|
finished_at = i.end_date
|
|
155
153
|
took += finished_at.strftime('%A %B %e at %I:%M%p')
|
|
156
154
|
|
|
157
|
-
|
|
158
155
|
took += ' and it took'
|
|
159
156
|
took += interval.time_string(format: :natural)
|
|
160
157
|
end
|
data/lib/doing/add_options.rb
CHANGED
|
@@ -45,7 +45,7 @@ def add_options(type, cmd, default_template: 'default')
|
|
|
45
45
|
cmd.arg_name 'FORMAT'
|
|
46
46
|
cmd.flag %i[o output], type: ExportTemplate
|
|
47
47
|
|
|
48
|
-
cmd.desc
|
|
48
|
+
cmd.desc 'Output using a template from configuration'
|
|
49
49
|
cmd.arg_name 'TEMPLATE_KEY'
|
|
50
50
|
cmd.flag [:config_template], type: TemplateName, default_value: default_template
|
|
51
51
|
|
|
@@ -57,7 +57,7 @@ def add_options(type, cmd, default_template: 'default')
|
|
|
57
57
|
cmd.arg_name 'FORMAT'
|
|
58
58
|
cmd.flag %i[o output]
|
|
59
59
|
|
|
60
|
-
cmd.desc
|
|
60
|
+
cmd.desc 'Output using a template from configuration'
|
|
61
61
|
cmd.arg_name 'TEMPLATE_KEY'
|
|
62
62
|
cmd.flag [:config_template], type: TemplateName
|
|
63
63
|
|
data/lib/doing/array/cleanup.rb
CHANGED
|
@@ -15,10 +15,10 @@ module BooleanTermParser
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
class QueryTransformer < Parslet::Transform
|
|
18
|
-
rule(:
|
|
18
|
+
rule(clause: subtree(:clause)) do
|
|
19
19
|
Clause.new(clause[:operator]&.to_s, clause[:term].to_s)
|
|
20
20
|
end
|
|
21
|
-
rule(:
|
|
21
|
+
rule(query: sequence(:clauses)) { Query.new(clauses) }
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
class Operator
|
|
@@ -49,7 +49,7 @@ module BooleanTermParser
|
|
|
49
49
|
attr_accessor :should_terms, :must_not_terms, :must_terms
|
|
50
50
|
|
|
51
51
|
def initialize(clauses)
|
|
52
|
-
grouped = clauses.chunk
|
|
52
|
+
grouped = clauses.chunk(&:operator).to_h
|
|
53
53
|
self.should_terms = grouped.fetch(:should, []).map(&:term)
|
|
54
54
|
self.must_not_terms = grouped.fetch(:must_not, []).map(&:term)
|
|
55
55
|
self.must_terms = grouped.fetch(:must, []).map(&:term)
|
|
@@ -6,7 +6,8 @@ module Doing
|
|
|
6
6
|
attr_reader :changes
|
|
7
7
|
attr_writer :changes_only
|
|
8
8
|
|
|
9
|
-
def initialize(lookup: nil, search: nil, changes: false, sort: :desc, prefix: false,
|
|
9
|
+
def initialize(lookup: nil, search: nil, changes: false, sort: :desc, prefix: false,
|
|
10
|
+
only: %i[changed new improved fixed])
|
|
10
11
|
@changes_only = changes
|
|
11
12
|
@prefix = prefix
|
|
12
13
|
@only = only
|
|
@@ -28,7 +29,7 @@ module Doing
|
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def versions
|
|
31
|
-
@changes.select { |change| change.entries&.count
|
|
32
|
+
@changes.select { |change| change.entries&.count&.> 0 }.map(&:version)
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def interactive
|
|
@@ -45,7 +46,7 @@ module Doing
|
|
|
45
46
|
|
|
46
47
|
def to_s
|
|
47
48
|
if @changes_only
|
|
48
|
-
@changes.map(&:changes_only).delete_if(&:empty?).join
|
|
49
|
+
@changes.map(&:changes_only).delete_if(&:empty?).join.gsub(/\n+/, "\n").force_encoding('utf-8')
|
|
49
50
|
else
|
|
50
51
|
@changes.map(&:to_s).join("\n\n").force_encoding('utf-8')
|
|
51
52
|
end
|
|
@@ -67,8 +68,6 @@ module Doing
|
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
def lookup(lookup_version)
|
|
70
|
-
range = []
|
|
71
|
-
|
|
72
71
|
if lookup_version =~ /([\d.]+) *(?:-|to)+ *([\d.]+)/
|
|
73
72
|
m = Regexp.last_match
|
|
74
73
|
lookup("> #{m[1]}")
|
|
@@ -36,7 +36,6 @@ module Doing
|
|
|
36
36
|
val.is_a?(String)
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
40
39
|
def compare(other, comp, inclusive: false)
|
|
41
40
|
case comp
|
|
42
41
|
when :older
|
|
@@ -81,18 +80,16 @@ module Doing
|
|
|
81
80
|
true
|
|
82
81
|
elsif wild?(other.min)
|
|
83
82
|
@min.to_s =~ /^#{other.min}/ ? true : false
|
|
84
|
-
|
|
85
|
-
if
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
@patch.to_s =~ /^#{other.patch}/ ? true : false
|
|
90
|
-
else
|
|
91
|
-
@patch == other.patch
|
|
92
|
-
end
|
|
83
|
+
elsif @min == other.min
|
|
84
|
+
if other.patch.nil?
|
|
85
|
+
true
|
|
86
|
+
elsif wild?(other.patch)
|
|
87
|
+
@patch.to_s =~ /^#{other.patch}/ ? true : false
|
|
93
88
|
else
|
|
94
|
-
|
|
89
|
+
@patch == other.patch
|
|
95
90
|
end
|
|
91
|
+
else
|
|
92
|
+
false
|
|
96
93
|
end
|
|
97
94
|
end
|
|
98
95
|
end
|
data/lib/doing/chronify/array.rb
CHANGED
|
@@ -9,12 +9,12 @@ module Doing
|
|
|
9
9
|
|
|
10
10
|
if d.zero? && h > 24
|
|
11
11
|
d = (h / 24).floor
|
|
12
|
-
h
|
|
12
|
+
h %= 24
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
if d > 365
|
|
16
16
|
y = (d / 365).floor
|
|
17
|
-
d
|
|
17
|
+
d %= 365
|
|
18
18
|
else
|
|
19
19
|
y = 0
|
|
20
20
|
end
|
|
@@ -41,7 +41,7 @@ module Doing
|
|
|
41
41
|
|
|
42
42
|
if d.zero? && h > 24
|
|
43
43
|
d = (h / 24).floor
|
|
44
|
-
h
|
|
44
|
+
h %= 24
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -68,7 +68,7 @@ module Doing
|
|
|
68
68
|
when :clock
|
|
69
69
|
if d.zero? && h > 24
|
|
70
70
|
d = (h / 24).floor
|
|
71
|
-
h
|
|
71
|
+
h %= 24
|
|
72
72
|
end
|
|
73
73
|
format('%<d>02d:%<h>02d:%<m>02d', d: d, h: h, m: m)
|
|
74
74
|
when :hmclock
|
|
@@ -43,8 +43,10 @@ module Doing
|
|
|
43
43
|
Doing.logger.debug('Parser:', %(date/time string "#{self}" interpreted as #{res} (#{secs_ago} seconds ago)))
|
|
44
44
|
else
|
|
45
45
|
date_string = dup
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if date_string.match(Types::REGEX_DAY) && now.strftime('%a') =~ /^#{Regexp.last_match(1)}/i
|
|
47
|
+
date_string = 'today'
|
|
48
|
+
end
|
|
49
|
+
date_string = "#{options[:context]} #{date_string}" if date_string =~ Types::REGEX_TIME && options[:context]
|
|
48
50
|
|
|
49
51
|
res = Chronic.parse(date_string, {
|
|
50
52
|
guess: options.fetch(:guess, :begin),
|
|
@@ -69,7 +71,7 @@ module Doing
|
|
|
69
71
|
##
|
|
70
72
|
def chronify_qty
|
|
71
73
|
minutes = 0
|
|
72
|
-
case
|
|
74
|
+
case strip
|
|
73
75
|
when /^(\d+):(\d\d)$/
|
|
74
76
|
minutes += Regexp.last_match(1).to_i * 60
|
|
75
77
|
minutes += Regexp.last_match(2).to_i
|
|
@@ -212,7 +214,6 @@ module Doing
|
|
|
212
214
|
|
|
213
215
|
end
|
|
214
216
|
|
|
215
|
-
|
|
216
217
|
if start.is_a? String
|
|
217
218
|
Doing.logger.debug('Parser:',
|
|
218
219
|
"--from string interpreted as time span, from #{start || '12am'} to #{finish || '11:59pm'}")
|
data/lib/doing/cli_status.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Status
|
|
2
4
|
def cols
|
|
3
5
|
@cols ||= `tput cols`.strip.to_i
|
|
@@ -11,11 +13,14 @@ module Status
|
|
|
11
13
|
tail = tail.join(', ')
|
|
12
14
|
end
|
|
13
15
|
tail.ltrunc!(max_width)
|
|
14
|
-
$stderr.print format(
|
|
16
|
+
$stderr.print format(
|
|
17
|
+
"#{esc['kill']}#{esc['boldyellow']}> #{esc['boldgreen']}%s #{esc['white']}[#{esc['boldwhite']}%#{@commands.count.to_s.length}d#{esc['boldblack']}/#{esc['boldyellow']}%d#{esc['white']}]: #{esc['boldcyan']}%s#{esc['default']}\r", msg, idx, total, tail
|
|
18
|
+
)
|
|
15
19
|
end
|
|
16
20
|
|
|
17
21
|
def status(msg, reset: true, end_char: "\n")
|
|
18
|
-
$stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg,
|
|
22
|
+
$stderr.print format("#{esc['kill']}#{esc['boldyellow']}> #{esc['whiteboard']}%s#{esc['default']}%s", msg,
|
|
23
|
+
reset ? "\r" : end_char)
|
|
19
24
|
end
|
|
20
25
|
|
|
21
26
|
def msg(msg, reset: true, color: 'green', end_char: "\n")
|
data/lib/doing/colors.rb
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
module Doing
|
|
5
5
|
# Terminal output color functions.
|
|
6
6
|
module Color
|
|
7
|
-
ESCAPE_REGEX =
|
|
7
|
+
ESCAPE_REGEX = /\e\[[0-9;]*m/.freeze
|
|
8
8
|
# All available color names. Available as methods and string extensions.
|
|
9
9
|
#
|
|
10
10
|
# @example Use a color as a method. Color reset will be added to end of string.
|
|
@@ -110,7 +110,9 @@ module Doing
|
|
|
110
110
|
compiled = ''
|
|
111
111
|
normalize_color.split('').each do |char|
|
|
112
112
|
compiled += char
|
|
113
|
-
|
|
113
|
+
if Color.attributes.include?(compiled.to_sym) || compiled =~ /^([fb]g?)?#([a-f0-9]{6})$/i
|
|
114
|
+
valid_color = compiled
|
|
115
|
+
end
|
|
114
116
|
end
|
|
115
117
|
|
|
116
118
|
valid_color
|
|
@@ -182,13 +184,49 @@ module Doing
|
|
|
182
184
|
escape += "\e[#{rgbf}m" if rgbf
|
|
183
185
|
escape + "\e[#{[fg, bg].delete_if(&:nil?).join(';')}m"
|
|
184
186
|
end
|
|
187
|
+
|
|
188
|
+
# Define string extension methods for all color attributes
|
|
189
|
+
ATTRIBUTES.each do |c, v|
|
|
190
|
+
new_method = <<-EOSCRIPT
|
|
191
|
+
def #{c}
|
|
192
|
+
result = ''
|
|
193
|
+
result << "\e[#{v}m" if Doing::Color.coloring?
|
|
194
|
+
result << self
|
|
195
|
+
result << "\e[0m" if Doing::Color.coloring?
|
|
196
|
+
result
|
|
197
|
+
end
|
|
198
|
+
EOSCRIPT
|
|
199
|
+
|
|
200
|
+
class_eval(new_method)
|
|
201
|
+
|
|
202
|
+
next unless c =~ /bold/
|
|
203
|
+
|
|
204
|
+
# Accept brightwhite in addition to boldwhite
|
|
205
|
+
new_method = <<-EOSCRIPT
|
|
206
|
+
def #{c.to_s.sub(/bold/, 'bright')}
|
|
207
|
+
result = ''
|
|
208
|
+
result << "\e[#{v}m" if Doing::Color.coloring?
|
|
209
|
+
result << self
|
|
210
|
+
result << "\e[0m" if Doing::Color.coloring?
|
|
211
|
+
result
|
|
212
|
+
end
|
|
213
|
+
EOSCRIPT
|
|
214
|
+
|
|
215
|
+
class_eval(new_method)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Returns an uncolored version of the string, that is all
|
|
219
|
+
# ANSI-sequences are stripped from the string.
|
|
220
|
+
def uncolor
|
|
221
|
+
gsub(ESCAPE_REGEX, '')
|
|
222
|
+
end
|
|
185
223
|
end
|
|
186
224
|
|
|
187
225
|
class << self
|
|
188
226
|
# Returns true if the coloring function of this module
|
|
189
227
|
# is switched on, false otherwise.
|
|
190
228
|
def coloring?
|
|
191
|
-
@coloring
|
|
229
|
+
@coloring.nil? ? true : @coloring
|
|
192
230
|
end
|
|
193
231
|
|
|
194
232
|
attr_writer :coloring
|
|
@@ -236,51 +274,62 @@ module Doing
|
|
|
236
274
|
|
|
237
275
|
fmt.empty? ? input : format(fmt, colors)
|
|
238
276
|
end
|
|
239
|
-
end
|
|
240
277
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
278
|
+
ATTRIBUTES.each do |c, v|
|
|
279
|
+
new_method = <<-EOSCRIPT
|
|
280
|
+
def #{c}(string = nil)
|
|
281
|
+
result = ''
|
|
282
|
+
result << "\e[#{v}m" if Doing::Color.coloring?
|
|
283
|
+
if block_given?
|
|
284
|
+
result << yield
|
|
285
|
+
elsif string.respond_to?(:to_str)
|
|
286
|
+
result << string.to_str
|
|
287
|
+
elsif respond_to?(:to_str)
|
|
288
|
+
result << to_str
|
|
289
|
+
else
|
|
290
|
+
return result #only switch on
|
|
291
|
+
end
|
|
292
|
+
result << "\e[0m" if Doing::Color.coloring?
|
|
293
|
+
result
|
|
254
294
|
end
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
295
|
+
EOSCRIPT
|
|
296
|
+
|
|
297
|
+
module_eval(new_method)
|
|
298
|
+
|
|
299
|
+
next unless c =~ /bold/
|
|
300
|
+
|
|
301
|
+
# Accept brightwhite in addition to boldwhite
|
|
302
|
+
new_method = <<-EOSCRIPT
|
|
303
|
+
def #{c.to_s.sub(/bold/, 'bright')}(string = nil)
|
|
304
|
+
result = ''
|
|
305
|
+
result << "\e[#{v}m" if Doing::Color.coloring?
|
|
306
|
+
if block_given?
|
|
307
|
+
result << yield
|
|
308
|
+
elsif string.respond_to?(:to_str)
|
|
309
|
+
result << string.to_str
|
|
310
|
+
elsif respond_to?(:to_str)
|
|
311
|
+
result << to_str
|
|
312
|
+
else
|
|
313
|
+
return result #only switch on
|
|
314
|
+
end
|
|
315
|
+
result << "\e[0m" if Doing::Color.coloring?
|
|
316
|
+
result
|
|
277
317
|
end
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
318
|
+
EOSCRIPT
|
|
319
|
+
|
|
320
|
+
module_eval(new_method)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Returns an array of all Doing::Color attributes as symbols.
|
|
324
|
+
def attributes
|
|
325
|
+
ATTRIBUTE_NAMES
|
|
326
|
+
end
|
|
282
327
|
|
|
283
|
-
|
|
328
|
+
# Returns an uncolored version of the string, that is all
|
|
329
|
+
# ANSI-sequences are stripped from the string.
|
|
330
|
+
def uncolor(string)
|
|
331
|
+
string.to_str.gsub(ESCAPE_REGEX, '')
|
|
332
|
+
end
|
|
284
333
|
end
|
|
285
334
|
|
|
286
335
|
def rgb(hex)
|
|
@@ -292,7 +341,6 @@ module Doing
|
|
|
292
341
|
%w[r g b].each do |e|
|
|
293
342
|
t << parts[e].hex
|
|
294
343
|
end
|
|
295
|
-
color =
|
|
296
344
|
"\e[#{is_bg ? '48' : '38'};2;#{t.join(';')}m"
|
|
297
345
|
end
|
|
298
346
|
|
|
@@ -309,11 +357,5 @@ module Doing
|
|
|
309
357
|
''
|
|
310
358
|
end
|
|
311
359
|
end
|
|
312
|
-
|
|
313
|
-
# Returns an array of all Doing::Color attributes as symbols.
|
|
314
|
-
def attributes
|
|
315
|
-
ATTRIBUTE_NAMES
|
|
316
|
-
end
|
|
317
|
-
extend self
|
|
318
360
|
end
|
|
319
361
|
end
|
|
@@ -11,35 +11,33 @@ module Doing
|
|
|
11
11
|
out = []
|
|
12
12
|
logic = []
|
|
13
13
|
|
|
14
|
-
@commands.each_with_index do |cmd,
|
|
14
|
+
@commands.each_with_index do |cmd, _i|
|
|
15
15
|
@bar.advance(status: cmd[:commands].first)
|
|
16
16
|
|
|
17
17
|
data = Completion.get_help_sections(cmd[:commands].first)
|
|
18
18
|
|
|
19
19
|
arg = data[:synopsis].join(' ').strip.split(/ /).last
|
|
20
|
-
case arg
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
type = case arg
|
|
21
|
+
when /(path|file)/i
|
|
22
|
+
:file
|
|
23
|
+
when /sect/i
|
|
24
|
+
'sections'
|
|
25
|
+
when /view/i
|
|
26
|
+
'views'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
next unless data[:command_options]
|
|
30
|
+
|
|
31
|
+
options = Completion.parse_options(data[:command_options])
|
|
32
|
+
out << command_function(cmd[:commands].first, options, type)
|
|
33
|
+
|
|
34
|
+
if first
|
|
35
|
+
op = 'if'
|
|
36
|
+
first = false
|
|
27
37
|
else
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
if data[:command_options]
|
|
32
|
-
options = Completion.parse_options(data[:command_options])
|
|
33
|
-
out << command_function(cmd[:commands].first, options, type)
|
|
34
|
-
|
|
35
|
-
if first
|
|
36
|
-
op = 'if'
|
|
37
|
-
first = false
|
|
38
|
-
else
|
|
39
|
-
op = 'elif'
|
|
40
|
-
end
|
|
41
|
-
logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
|
|
38
|
+
op = 'elif'
|
|
42
39
|
end
|
|
40
|
+
logic << %(#{op} [[ $last =~ (#{cmd[:commands].join('|')}) ]]; then _doing_#{cmd[:commands].first})
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
out << <<~EOFUNC
|
|
@@ -71,25 +69,23 @@ module Doing
|
|
|
71
69
|
short_options << o[:short] if o[:short]
|
|
72
70
|
end
|
|
73
71
|
|
|
74
|
-
long = long_options.map! {|o| "--#{o}"}.join(' ')
|
|
75
|
-
short = short_options.map! {|o| "-#{o}"}.join(' ')
|
|
72
|
+
long = long_options.map! { |o| "--#{o}" }.join(' ')
|
|
73
|
+
short = short_options.map! { |o| "-#{o}" }.join(' ')
|
|
76
74
|
words = ''
|
|
77
75
|
logic = ''
|
|
78
|
-
words, logic = get_words(type) if type
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
words, logic = get_words(type) if type.is_a?(String)
|
|
77
|
+
|
|
78
|
+
<<~ENDFUNC
|
|
79
|
+
_doing_#{command}() {
|
|
80
|
+
#{words}
|
|
81
|
+
if [[ "$token" == --* ]]; then
|
|
82
|
+
COMPREPLY=( $( compgen -W '#{long}' -- $token ) )
|
|
83
|
+
elif [[ "$token" == -* ]]; then
|
|
84
|
+
COMPREPLY=( $( compgen -W '#{short} #{long}' -- $token ) )
|
|
85
|
+
#{logic}
|
|
86
|
+
fi
|
|
87
|
+
}
|
|
90
88
|
ENDFUNC
|
|
91
|
-
|
|
92
|
-
func
|
|
93
89
|
end
|
|
94
90
|
|
|
95
91
|
def get_words(type)
|
|
@@ -126,7 +122,8 @@ module Doing
|
|
|
126
122
|
data = Completion.get_help_sections
|
|
127
123
|
@global_options = Completion.parse_options(data[:global_options])
|
|
128
124
|
@commands = Completion.parse_commands(data[:commands])
|
|
129
|
-
@bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m",
|
|
125
|
+
@bar = TTY::ProgressBar.new("\033[0;0;33mGenerating Bash completions: \033[0;35;40m[:bar] :status\033[0m",
|
|
126
|
+
total: @commands.count + 1, bar_format: :square, hide_cursor: true, status: 'Reading subcommands')
|
|
130
127
|
width = TTY::Screen.columns - 45
|
|
131
128
|
@bar.resize(width)
|
|
132
129
|
end
|