doing 2.1.41 → 2.1.42
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/CHANGELOG.md +22 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/bin/commands/again.rb +1 -3
- data/bin/commands/changes.rb +50 -34
- data/bin/commands/commands.rb +77 -52
- data/bin/commands/commands_accepting.rb +57 -53
- data/bin/commands/config.rb +2 -2
- data/bin/commands/finish.rb +94 -68
- data/bin/commands/flag.rb +5 -1
- data/bin/commands/now.rb +151 -107
- data/bin/commands/on.rb +7 -4
- data/bin/commands/undo.rb +4 -6
- data/docs/doc/Array.html +3 -2
- data/docs/doc/BooleanTermParser/Clause.html +1 -1
- data/docs/doc/BooleanTermParser/Operator.html +1 -1
- data/docs/doc/BooleanTermParser/Query.html +1 -1
- data/docs/doc/BooleanTermParser/QueryParser.html +1 -1
- data/docs/doc/BooleanTermParser/QueryTransformer.html +1 -1
- data/docs/doc/BooleanTermParser.html +1 -1
- data/docs/doc/Doing/ArrayNestedHash.html +1 -1
- data/docs/doc/Doing/ArrayTags.html +1 -1
- data/docs/doc/Doing/CSVExport.html +1 -1
- data/docs/doc/Doing/CalendarImport.html +1 -1
- data/docs/doc/Doing/Change.html +1 -1
- data/docs/doc/Doing/Changes.html +1 -1
- data/docs/doc/Doing/ChronifyArray.html +1 -1
- data/docs/doc/Doing/ChronifyNumeric.html +1 -1
- data/docs/doc/Doing/ChronifyString.html +1 -1
- data/docs/doc/Doing/Color.html +1 -1
- data/docs/doc/Doing/Completion/BashCompletions.html +1 -1
- data/docs/doc/Doing/Completion/FishCompletions.html +1 -1
- data/docs/doc/Doing/Completion/StringUtils.html +1 -1
- data/docs/doc/Doing/Completion/ZshCompletions.html +1 -1
- data/docs/doc/Doing/Completion.html +1 -1
- data/docs/doc/Doing/Configuration.html +3 -2
- data/docs/doc/Doing/DayOneRenderer.html +1 -1
- data/docs/doc/Doing/DayoneExport.html +1 -1
- data/docs/doc/Doing/DoingImport.html +1 -1
- data/docs/doc/Doing/Entry.html +1 -1
- data/docs/doc/Doing/Errors/DoingNoTraceError.html +1 -1
- data/docs/doc/Doing/Errors/DoingRuntimeError.html +1 -1
- data/docs/doc/Doing/Errors/DoingStandardError.html +1 -1
- data/docs/doc/Doing/Errors/EmptyInput.html +1 -1
- data/docs/doc/Doing/Errors/HistoryLimitError.html +1 -1
- data/docs/doc/Doing/Errors/InvalidPlugin.html +1 -1
- data/docs/doc/Doing/Errors/MissingBackupFile.html +1 -1
- data/docs/doc/Doing/Errors/NoResults.html +1 -1
- data/docs/doc/Doing/Errors/PluginException.html +1 -1
- data/docs/doc/Doing/Errors/UserCancelled.html +1 -1
- data/docs/doc/Doing/Errors/WrongCommand.html +1 -1
- data/docs/doc/Doing/Errors.html +1 -1
- data/docs/doc/Doing/HTMLExport.html +1 -1
- data/docs/doc/Doing/Hooks.html +1 -1
- data/docs/doc/Doing/Item.html +1 -1
- data/docs/doc/Doing/ItemDates.html +1 -1
- data/docs/doc/Doing/ItemQuery.html +1 -1
- data/docs/doc/Doing/ItemState.html +1 -1
- data/docs/doc/Doing/ItemTags.html +1 -1
- data/docs/doc/Doing/Items.html +2 -1
- data/docs/doc/Doing/JSONExport.html +1 -1
- data/docs/doc/Doing/Logger.html +1 -1
- data/docs/doc/Doing/MarkdownExport.html +1 -1
- data/docs/doc/Doing/Note.html +3 -2
- data/docs/doc/Doing/Pager.html +1 -1
- data/docs/doc/Doing/Plugins.html +181 -76
- data/docs/doc/Doing/Prompt.html +1 -1
- data/docs/doc/Doing/PromptChoose.html +1 -1
- data/docs/doc/Doing/PromptFZF.html +1 -1
- data/docs/doc/Doing/PromptInput.html +1 -1
- data/docs/doc/Doing/PromptSTD.html +1 -1
- data/docs/doc/Doing/PromptYN.html +1 -1
- data/docs/doc/Doing/Section.html +1 -1
- data/docs/doc/Doing/StringHighlight.html +1 -1
- data/docs/doc/Doing/StringNormalize.html +1 -1
- data/docs/doc/Doing/StringQuery.html +1 -1
- data/docs/doc/Doing/StringTags.html +1 -1
- data/docs/doc/Doing/StringTransform.html +35 -1
- data/docs/doc/Doing/StringTruncate.html +1 -1
- data/docs/doc/Doing/StringURL.html +1 -1
- data/docs/doc/Doing/SymbolNormalize.html +1 -1
- data/docs/doc/Doing/TaskPaperExport.html +1 -1
- data/docs/doc/Doing/TemplateExport.html +1 -1
- data/docs/doc/Doing/TemplateString.html +2 -2
- data/docs/doc/Doing/TimingImport.html +1 -1
- data/docs/doc/Doing/Types.html +1 -1
- data/docs/doc/Doing/Util/Backup.html +2 -156
- data/docs/doc/Doing/Util.html +66 -9
- data/docs/doc/Doing/Version.html +1 -1
- data/docs/doc/Doing/WWID.html +14 -1
- data/docs/doc/Doing.html +4 -4
- data/docs/doc/FalseClass.html +1 -1
- data/docs/doc/GLI/Commands/Help.html +1 -1
- data/docs/doc/GLI/Commands/MarkdownDocumentListener.html +1 -1
- data/docs/doc/GLI/Commands.html +1 -1
- data/docs/doc/GLI.html +1 -1
- data/docs/doc/Hash.html +1 -1
- data/docs/doc/Numeric.html +1 -1
- data/docs/doc/Object.html +1 -1
- data/docs/doc/PhraseParser/Operator.html +1 -1
- data/docs/doc/PhraseParser/PhraseClause.html +1 -1
- data/docs/doc/PhraseParser/Query.html +1 -1
- data/docs/doc/PhraseParser/QueryParser.html +1 -1
- data/docs/doc/PhraseParser/QueryTransformer.html +1 -1
- data/docs/doc/PhraseParser/TermClause.html +1 -1
- data/docs/doc/PhraseParser.html +1 -1
- data/docs/doc/Status.html +1 -1
- data/docs/doc/String.html +2 -2
- data/docs/doc/Symbol.html +1 -1
- data/docs/doc/Time.html +1 -1
- data/docs/doc/TrueClass.html +1 -1
- data/docs/doc/_index.html +16 -9
- data/docs/doc/class_list.html +1 -1
- data/docs/doc/file.README.html +2 -2
- data/docs/doc/index.html +2 -2
- data/docs/doc/method_list.html +289 -281
- data/docs/doc/top-level-namespace.html +9 -1
- data/doing.rdoc +7 -7
- data/lib/doing/add_options.rb +8 -0
- data/lib/doing/array/array.rb +2 -0
- data/lib/doing/array/cleanup.rb +31 -0
- data/lib/doing/configuration.rb +7 -3
- data/lib/doing/note.rb +1 -1
- data/lib/doing/pager.rb +9 -3
- data/lib/doing/plugin_manager.rb +30 -5
- data/lib/doing/prompt/choose.rb +1 -1
- data/lib/doing/prompt/input.rb +1 -1
- data/lib/doing/string/transform.rb +6 -0
- data/lib/doing/util.rb +12 -6
- data/lib/doing/util_backup.rb +55 -48
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid/editor.rb +6 -3
- data/lib/doing/wwid/interactive.rb +10 -20
- data/lib/doing/wwid/modify.rb +2 -0
- data/lib/doing.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8021e76952eb60e4eb68c5aa013f558e7e9e5db454bad792c1ae7e5cc495e24c
|
|
4
|
+
data.tar.gz: 5eda874992b4f9648c421afdc4429963f2614d08aabba8fb338d4d27c353e258
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37ce93cc4868cbb5565f18b8cd2a77d61099f9692c5b6bcaacdf9329876faa4bc9ff240adc29ea2f8e4cff76adbadc697f583131dfcdb61379dc998a91d40de4
|
|
7
|
+
data.tar.gz: 06d59cd04607005a65f166701873107a8d4817986007940489dfda3247d97d567a4072d62eb05687f50e1ba93eb6341f1db8f5a317df948836fa56945270a8fa
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
### 2.1.42
|
|
2
|
+
|
|
3
|
+
2022-03-17 09:38
|
|
4
|
+
|
|
5
|
+
#### NEW
|
|
6
|
+
|
|
7
|
+
- Config option `editors.pager` allows you to force a pager (ignore env settings)
|
|
8
|
+
|
|
9
|
+
#### IMPROVED
|
|
10
|
+
|
|
11
|
+
- Change pager preference order to $PAGER, less -Xr, $GIT_PAGER
|
|
12
|
+
- Remove `bat` from pager options as it just falls back to `less -Xr` anyway
|
|
13
|
+
- Using CTRL-C when entring a note interactively won't cancel the whole operation, just the note
|
|
14
|
+
|
|
15
|
+
#### FIXED
|
|
16
|
+
|
|
17
|
+
- Add delay between `doing select --editor` and opening the editor, fixes some TTY echo issues
|
|
18
|
+
- If `doing last --editor` has no changes, exit gracefully
|
|
19
|
+
- Trigger pre/post_write hooks when using undo/redo
|
|
20
|
+
- `doing config set` issues with keys that default to nil
|
|
21
|
+
- Notification for `doing config set --remove` missing last element of key path
|
|
22
|
+
|
|
1
23
|
### 2.1.41
|
|
2
24
|
|
|
3
25
|
2022-03-16 09:29
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ _If you're one of the rare people like me who find this useful, feel free to
|
|
|
8
8
|
|
|
9
9
|
<!--README-->
|
|
10
10
|
|
|
11
|
-
The current version of `doing` is <!--VER-->2.1.
|
|
11
|
+
The current version of `doing` is <!--VER-->2.1.41<!--END VER-->.
|
|
12
12
|
|
|
13
13
|
Find all of the documentation in the [doing wiki][wiki].
|
|
14
14
|
|
data/bin/commands/again.rb
CHANGED
|
@@ -33,9 +33,7 @@ command %i[again resume] do |c|
|
|
|
33
33
|
c.action do |_global_options, options, _args|
|
|
34
34
|
options[:fuzzy] = false
|
|
35
35
|
|
|
36
|
-
if options[:search]
|
|
37
|
-
options[:search] = options[:exact] ? options[:search].sub(/^'?/, "'") : options[:search]
|
|
38
|
-
end
|
|
36
|
+
options[:search] = options[:search].sub(/^'?/, "'") if options[:search] && options[:exact]
|
|
39
37
|
|
|
40
38
|
if options[:back]
|
|
41
39
|
options[:date] = options[:back]
|
data/bin/commands/changes.rb
CHANGED
|
@@ -14,52 +14,68 @@ MARKDOWN_THEME = {
|
|
|
14
14
|
comment: :bright_black
|
|
15
15
|
}.deep_freeze
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
module Doing
|
|
18
|
+
# changes command methods
|
|
19
|
+
class ChangesCommand
|
|
20
|
+
CHANGE_RX = /^(?:(?:(?:[<>=]+|p(?:rior)|b(?:efore)|o(?:lder)|s(?:ince)|a(?:fter)|n(?:ewer))? *[0-9.*?]{1,10} *)+|(?:[\d.]+ *(?:-|to)+ *[0-9.]{1,10}))$/
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
def add_options(cmd)
|
|
23
|
+
cmd.desc 'Display all versions'
|
|
24
|
+
cmd.switch %i[a all], default_value: false, negatable: false
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
cmd.desc %(Look up a specific version. Specify versions as "MAJ.MIN.PATCH", MIN
|
|
27
|
+
and PATCH are optional. Use > or < to see all changes since or prior
|
|
28
|
+
to a version. Wildcards (*?) accepted unless using < or >.)
|
|
29
|
+
cmd.arg_name 'VERSION'
|
|
30
|
+
cmd.flag %i[l lookup], must_match: CHANGE_RX
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
c.arg_name 'VERSION'
|
|
32
|
-
c.flag %i[l lookup], must_match: CHANGE_RX
|
|
32
|
+
cmd.desc %(Show changelogs matching search terms (uses pattern-based searching).
|
|
33
|
+
Add slashes to search with regular expressions, e.g. `--search "/output.*flag/"`)
|
|
34
|
+
cmd.flag %i[s search]
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
cmd.desc 'Sort order (asc/desc)'
|
|
37
|
+
cmd.arg_name 'ORDER'
|
|
38
|
+
cmd.flag %i[sort], must_match: REGEX_SORT_ORDER, default_value: :desc, type: OrderSymbol
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
c.flag %i[sort], must_match: REGEX_SORT_ORDER, default_value: :desc, type: OrderSymbol
|
|
40
|
+
cmd.desc 'Only output changes, no version numbers, headers, or dates'
|
|
41
|
+
cmd.switch %i[C changes], default_value: false, negatable: false
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
cmd.desc 'Output raw Markdown'
|
|
44
|
+
cmd.switch %i[m md markdown], default_value: false, negatable: false
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
cmd.desc 'Force rendered output'
|
|
47
|
+
cmd.switch %i[render], default_value: false, negatable: false
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
cmd.desc 'Open changelog in interactive viewer'
|
|
50
|
+
cmd.switch %i[i interactive], default_value: false, negatable: false
|
|
51
|
+
end
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
def add_examples(cmd)
|
|
54
|
+
cmd.example 'doing changes', desc: 'View changes in the current version'
|
|
55
|
+
cmd.example 'doing changes --all', desc: 'See the entire changelog'
|
|
56
|
+
cmd.example 'doing changes --lookup 2.0.21', desc: 'See changes from version 2.0.21'
|
|
57
|
+
cmd.example 'doing changes --lookup "> 2.1"', desc: 'See all changes since 2.1.0'
|
|
58
|
+
cmd.example 'doing changes --search "tags +bool"', desc: 'See all changes containing "tags" and "bool"'
|
|
59
|
+
cmd.example 'doing changes -l "> 2.1" -s "pattern"', desc: 'Lookup and search can be combined'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
desc 'List recent changes in Doing'
|
|
65
|
+
long_desc %(Display a formatted list of changes in recent versions.
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
c
|
|
59
|
-
c
|
|
67
|
+
Without flags, displays only the most recent version.
|
|
68
|
+
Use --lookup or --all for history.)
|
|
69
|
+
command %i[changes changelog] do |c|
|
|
70
|
+
cmd = Doing::ChangesCommand.new
|
|
71
|
+
cmd.add_options(c)
|
|
72
|
+
cmd.add_examples(c)
|
|
60
73
|
|
|
61
74
|
c.action do |_global_options, options, _args|
|
|
62
|
-
cl = Doing::Changes.new(lookup: options[:lookup],
|
|
75
|
+
cl = Doing::Changes.new(lookup: options[:lookup],
|
|
76
|
+
search: options[:search],
|
|
77
|
+
changes: options[:changes],
|
|
78
|
+
sort: options[:sort])
|
|
63
79
|
|
|
64
80
|
if options[:interactive]
|
|
65
81
|
cl.interactive
|
data/bin/commands/commands.rb
CHANGED
|
@@ -1,37 +1,71 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
module Doing
|
|
4
|
+
# commands command methods
|
|
5
|
+
class CommandsCommand
|
|
6
|
+
def add_examples(cmd)
|
|
7
|
+
cmd.example 'doing commands add', desc: 'Get a menu of available commands'
|
|
8
|
+
cmd.example 'doing commands add COMMAND', desc: 'Specify a command to enable'
|
|
9
|
+
cmd.example 'doing commands remove COMMAND', desc: 'Specify a command to disable'
|
|
10
|
+
end
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
def remove_command(args)
|
|
13
|
+
available = Dir.glob(File.join(File.dirname(__FILE__), '*.rb')).map { |cmd| File.basename(cmd, '.rb') }
|
|
14
|
+
cfg = Doing.settings
|
|
15
|
+
custom_dir = Doing.setting('plugins.command_path')
|
|
16
|
+
custom_commands = Dir.glob(File.join(File.expand_path(custom_dir), '*.rb'))
|
|
17
|
+
available.concat(custom_commands.map { |cmd| File.basename(cmd, '.rb') })
|
|
18
|
+
disabled = Doing.setting('disabled_commands')
|
|
19
|
+
disabled.each { |cmd| available.delete(cmd) }
|
|
20
|
+
to_disable = if args.good?
|
|
21
|
+
args
|
|
22
|
+
else
|
|
23
|
+
Prompt.choose_from(available,
|
|
24
|
+
prompt: 'Select commands to enable',
|
|
25
|
+
multiple: true,
|
|
26
|
+
sorted: true)
|
|
27
|
+
end
|
|
28
|
+
raise UserCancelled unless to_disable.good?
|
|
11
29
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
30
|
+
to_disable = to_disable.strip.split("\n") if to_disable.is_a?(String)
|
|
31
|
+
|
|
32
|
+
to_disable.each do |cmd|
|
|
33
|
+
default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
|
|
34
|
+
custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
|
|
35
|
+
unless File.exist?(default_command) || File.exist?(custom_command)
|
|
36
|
+
raise InvalidArgument, "Command #{cmd} not found"
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
raise InvalidArgument, "Command #{cmd} is not enabled" unless available.include?(cmd)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
cfg.deep_set(['disabled_commands'], disabled.concat(to_disable))
|
|
44
|
+
|
|
45
|
+
Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
|
|
46
|
+
Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def add_command(args)
|
|
18
50
|
cfg = Doing.settings
|
|
19
|
-
custom_dir =
|
|
51
|
+
custom_dir = Doing.setting('plugins.command_path')
|
|
52
|
+
available = Doing.setting('disabled_commands')
|
|
20
53
|
|
|
21
|
-
available = cfg['disabled_commands']
|
|
22
54
|
raise UserCancelled, 'No commands available to enable' unless args.good? || available.good?
|
|
23
55
|
|
|
24
56
|
to_enable = if args.good?
|
|
25
57
|
args
|
|
26
58
|
else
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
59
|
+
Prompt.choose_from(available,
|
|
60
|
+
prompt: 'Select commands to enable',
|
|
61
|
+
multiple: true,
|
|
62
|
+
sorted: true)
|
|
31
63
|
end
|
|
32
|
-
raise UserCancelled unless to_enable
|
|
64
|
+
raise UserCancelled unless to_enable.good?
|
|
33
65
|
|
|
34
|
-
to_enable.strip.split("\n")
|
|
66
|
+
to_enable = to_enable.strip.split("\n") if to_enable.is_a?(String)
|
|
67
|
+
|
|
68
|
+
to_enable.each do |cmd|
|
|
35
69
|
default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
|
|
36
70
|
custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
|
|
37
71
|
unless File.exist?(default_command) || File.exist?(custom_command)
|
|
@@ -45,45 +79,36 @@ command :commands do |c|
|
|
|
45
79
|
|
|
46
80
|
cfg.deep_set(['disabled_commands'], available)
|
|
47
81
|
|
|
48
|
-
|
|
82
|
+
Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
|
|
49
83
|
Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
|
|
50
84
|
end
|
|
51
85
|
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# @@commands
|
|
89
|
+
desc 'Enable and disable Doing commands'
|
|
90
|
+
command :commands do |c|
|
|
91
|
+
c.default_command :add
|
|
92
|
+
|
|
93
|
+
cmd = Doing::CommandsCommand.new
|
|
94
|
+
|
|
95
|
+
cmd.add_examples(c)
|
|
96
|
+
|
|
97
|
+
# @@commands.enable
|
|
98
|
+
c.desc 'Enable Doing commands'
|
|
99
|
+
c.long_desc 'Run without arguments to select commands from a list.'
|
|
100
|
+
c.arg_name 'COMMAND [COMMAND...]'
|
|
101
|
+
c.command %i[add enable] do |add|
|
|
102
|
+
add.action do |_global, _options, args|
|
|
103
|
+
cmd.add_command(args)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
52
106
|
|
|
53
107
|
# @@commands.disable
|
|
54
108
|
c.desc 'Disable Doing commands'
|
|
55
109
|
c.command %i[remove disable] do |remove|
|
|
56
110
|
remove.action do |_global, _options, args|
|
|
57
|
-
|
|
58
|
-
cfg = Doing.settings
|
|
59
|
-
custom_dir = cfg.dig('plugins', 'command_path')
|
|
60
|
-
custom_commands = Dir.glob(File.join(File.expand_path(custom_dir), '*.rb'))
|
|
61
|
-
available.concat(custom_commands.map { |cmd| File.basename(cmd, '.rb') })
|
|
62
|
-
disabled = cfg['disabled_commands']
|
|
63
|
-
disabled.each { |cmd| available.delete(cmd) }
|
|
64
|
-
to_disable = if args.good?
|
|
65
|
-
args
|
|
66
|
-
else
|
|
67
|
-
Doing::Prompt.choose_from(available,
|
|
68
|
-
prompt: 'Select commands to enable',
|
|
69
|
-
multiple: true,
|
|
70
|
-
sorted: true).strip.split("\n")
|
|
71
|
-
end
|
|
72
|
-
to_disable.each do |cmd|
|
|
73
|
-
default_command = File.join(File.dirname(__FILE__), "#{cmd}.rb")
|
|
74
|
-
custom_command = File.join(File.expand_path(custom_dir), "#{cmd}.rb")
|
|
75
|
-
unless File.exist?(default_command) || File.exist?(custom_command)
|
|
76
|
-
raise InvalidArgument, "Command #{cmd} not found"
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
raise InvalidArgument, "Command #{cmd} is not enabled" unless available.include?(cmd)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
cfg.deep_set(['disabled_commands'], disabled.concat(to_disable))
|
|
84
|
-
|
|
85
|
-
Doing::Util.write_to_file(Doing.config.config_file, YAML.dump(cfg), backup: true)
|
|
86
|
-
Doing.logger.warn('Config:', "#{Doing.config.config_file} updated")
|
|
111
|
+
cmd.remove_command(args)
|
|
87
112
|
end
|
|
88
113
|
end
|
|
89
114
|
end
|
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
module Doing
|
|
4
|
+
# commands_accepting command methods
|
|
5
|
+
class CommandsAcceptingCommand
|
|
6
|
+
def flags?(options, args, bool)
|
|
7
|
+
case bool
|
|
8
|
+
when :and
|
|
9
|
+
all_flags?(options, args)
|
|
10
|
+
when :not
|
|
11
|
+
no_flags?(options, args)
|
|
12
|
+
else
|
|
13
|
+
any_flags?(options, args)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def all_flags?(options, args)
|
|
18
|
+
args.each do |arg|
|
|
19
|
+
has_flag = false
|
|
20
|
+
options.flags.merge(options.switches).each do |_, flag|
|
|
21
|
+
if flag.name == arg.to_sym || flag.aliases&.include?(arg.to_sym)
|
|
22
|
+
has_flag = true
|
|
23
|
+
break
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
return false unless has_flag
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def any_flags?(options, args)
|
|
33
|
+
args.each do |option|
|
|
34
|
+
options.flags.merge(options.switches).each do |_, flag|
|
|
35
|
+
return true if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def no_flags?(options, args)
|
|
43
|
+
args.each do |option|
|
|
44
|
+
options.flags.merge(options.switches).each do |_, flag|
|
|
45
|
+
return false if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
true
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
3
54
|
# @@commands_accepting
|
|
4
55
|
arg_name 'OPTION'
|
|
5
56
|
command :commands_accepting do |c|
|
|
@@ -11,66 +62,19 @@ command :commands_accepting do |c|
|
|
|
11
62
|
default_value: :and,
|
|
12
63
|
type: BooleanSymbol
|
|
13
64
|
|
|
14
|
-
c.action do |
|
|
65
|
+
c.action do |_g, o, a|
|
|
66
|
+
cac = Doing::CommandsAcceptingCommand.new
|
|
15
67
|
cmds = []
|
|
16
|
-
commands.each { |cmd, v| cmds.push(cmd) if
|
|
68
|
+
commands.each { |cmd, v| cmds.push(cmd) if cac.flags?(v, a, o[:bool]) }
|
|
17
69
|
|
|
18
70
|
if o[:column]
|
|
19
71
|
puts cmds.sort
|
|
20
72
|
else
|
|
21
|
-
description =
|
|
22
|
-
description +=
|
|
23
|
-
description +=
|
|
73
|
+
description = 'Commands '
|
|
74
|
+
description += 'not ' if o[:bool] == :not
|
|
75
|
+
description += 'accepting '
|
|
24
76
|
description += a.map { |arg| "--#{arg}" }.join(o[:bool] == :and ? ' and ' : ' or ')
|
|
25
77
|
puts "#{description}: #{cmds.sort.join(', ')}"
|
|
26
78
|
end
|
|
27
79
|
end
|
|
28
|
-
|
|
29
|
-
def has_flags?(options, args, bool)
|
|
30
|
-
case bool
|
|
31
|
-
when :and
|
|
32
|
-
all_flags?(options, args)
|
|
33
|
-
when :not
|
|
34
|
-
no_flags?(options, args)
|
|
35
|
-
else
|
|
36
|
-
any_flags?(options, args)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def all_flags?(options, args)
|
|
41
|
-
args.each do |arg|
|
|
42
|
-
has_flag = false
|
|
43
|
-
options.flags.merge(options.switches).each do |_, flag|
|
|
44
|
-
if flag.name == arg.to_sym || flag.aliases&.include?(arg.to_sym)
|
|
45
|
-
has_flag = true
|
|
46
|
-
break
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
return false unless has_flag
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def any_flags?(options, args)
|
|
56
|
-
args.each do |option|
|
|
57
|
-
options.flags.merge(options.switches).each do |_, flag|
|
|
58
|
-
return true if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
false
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def no_flags?(options, args)
|
|
66
|
-
args.each do |option|
|
|
67
|
-
options.flags.merge(options.switches).each do |_, flag|
|
|
68
|
-
return false if flag.name == option.to_sym || flag.aliases&.include?(option.to_sym)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
true
|
|
73
|
-
end
|
|
74
80
|
end
|
|
75
|
-
|
|
76
|
-
|
data/bin/commands/config.rb
CHANGED
|
@@ -214,7 +214,7 @@ command :config do |c|
|
|
|
214
214
|
keypath = args.join('.')
|
|
215
215
|
real_path = Doing.config.resolve_key_path(keypath, create: true)
|
|
216
216
|
old_value = Doing.config.settings.dig(*real_path)
|
|
217
|
-
old_type = old_value&.class.to_s
|
|
217
|
+
old_type = old_value.good? ? old_value&.class.to_s : nil
|
|
218
218
|
|
|
219
219
|
if old_value.is_a?(Hash) && !options[:remove]
|
|
220
220
|
Doing.logger.log_now(:warn, 'Config:', ['Config key must point to a single value, ',
|
|
@@ -235,8 +235,8 @@ command :config do |c|
|
|
|
235
235
|
$stderr.puts "> Config: Updating #{config_file}".yellow
|
|
236
236
|
|
|
237
237
|
if options[:remove]
|
|
238
|
-
cfg.deep_set(real_path, nil)
|
|
239
238
|
$stderr.puts "#{'Deleting key:'.yellow} #{real_path.join('.').boldwhite}"
|
|
239
|
+
cfg.deep_set(real_path, nil)
|
|
240
240
|
else
|
|
241
241
|
current_value = cfg.dig(*real_path)
|
|
242
242
|
cfg.deep_set(real_path, value.set_type(old_type))
|