wile 0.9.261203

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.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.version +1 -0
  3. data/CREDITS.md +20 -0
  4. data/README.md +253 -0
  5. data/bin/wile +102 -0
  6. data/cache/.bin/pane +99 -0
  7. data/cache/.bin/panes +54 -0
  8. data/cache/.config.fish +2 -0
  9. data/cache/.dictionary +0 -0
  10. data/cache/.gemignore +16 -0
  11. data/cache/.gitignore +9 -0
  12. data/cache/.greeting.erb +1 -0
  13. data/cache/.irbrc +30 -0
  14. data/cache/.lexicon +0 -0
  15. data/cache/.prompt.erb +1 -0
  16. data/cache/.reek-strict.yml +1 -0
  17. data/cache/.reek.yml +1 -0
  18. data/cache/.rubocop-strict.yml +4 -0
  19. data/cache/.rubocop.yml +4 -0
  20. data/cache/.ruby-version-floor +1 -0
  21. data/cache/.ruby-version.erb +1 -0
  22. data/cache/.solargraph.yml +21 -0
  23. data/cache/.title.erb +1 -0
  24. data/cache/.version +1 -0
  25. data/cache/.wile/example.rb +56 -0
  26. data/cache/.wileignore +3 -0
  27. data/cache/CREDITS.md +10 -0
  28. data/cache/Gemfile +5 -0
  29. data/cache/Gemfile.lock +1 -0
  30. data/cache/History.txt +0 -0
  31. data/cache/README.md.erb +54 -0
  32. data/cache/TODO.md +3 -0
  33. data/cache/bin/project.erb +12 -0
  34. data/cache/cucumber.yml +1 -0
  35. data/cache/examples/README.md +3 -0
  36. data/cache/features/help.feature.erb +30 -0
  37. data/cache/features/step_definitions/command_steps.rb +171 -0
  38. data/cache/features/support/env.rb +11 -0
  39. data/cache/features/version.feature.erb +19 -0
  40. data/cache/git/hooks/pre-commit +93 -0
  41. data/cache/lib/project.rb.erb +4 -0
  42. data/cache/man/project.md.erb +24 -0
  43. data/cache/pkg/README.md +3 -0
  44. data/cache/test/cons.gz +0 -0
  45. data/cache/test/tc_comments +216 -0
  46. data/cache/test/tc_cucumber_slow +67 -0
  47. data/cache/test/tc_dependency_scrapes +126 -0
  48. data/cache/test/tc_dictionary +51 -0
  49. data/cache/test/tc_encoding +53 -0
  50. data/cache/test/tc_lexicon +34 -0
  51. data/cache/test/tc_lib_tests +37 -0
  52. data/cache/test/tc_lints +71 -0
  53. data/cache/test/tc_readme_rocket_check +128 -0
  54. data/cache/test/tc_reek +20 -0
  55. data/cache/test/tc_rubocop +20 -0
  56. data/cache/test/tc_ruby_syntax +28 -0
  57. data/cache/test/tc_tags +32 -0
  58. data/cache/test/tc_tasks_test +31 -0
  59. data/cache/test/tc_version +97 -0
  60. data/cache/test/tc_weird_filenames +23 -0
  61. data/cache/test/test_helper.rb +230 -0
  62. data/cache/tmp/README.md +8 -0
  63. data/data/command_version.tsv +281 -0
  64. data/dependencies.txt +70 -0
  65. data/lib/wile/autoloads/cache.rb +123 -0
  66. data/lib/wile/autoloads/code_content.rb +225 -0
  67. data/lib/wile/autoloads/code_data.rb +153 -0
  68. data/lib/wile/autoloads/code_data_function.rb +79 -0
  69. data/lib/wile/autoloads/code_data_valuation.rb +60 -0
  70. data/lib/wile/autoloads/code_stats.rb +185 -0
  71. data/lib/wile/autoloads/command_version.rb +119 -0
  72. data/lib/wile/autoloads/content.rb +196 -0
  73. data/lib/wile/autoloads/dependencies.rb +170 -0
  74. data/lib/wile/autoloads/gem_utils.rb +69 -0
  75. data/lib/wile/autoloads/gemspec.rb +163 -0
  76. data/lib/wile/autoloads/git.rb +59 -0
  77. data/lib/wile/autoloads/info.rb +91 -0
  78. data/lib/wile/autoloads/manpage.rb +44 -0
  79. data/lib/wile/autoloads/methods.rb +130 -0
  80. data/lib/wile/autoloads/nvim_files.rb +54 -0
  81. data/lib/wile/autoloads/options_dictionary.rb +345 -0
  82. data/lib/wile/autoloads/order_optimizer.rb +185 -0
  83. data/lib/wile/autoloads/project.rb +60 -0
  84. data/lib/wile/autoloads/readme.rb +137 -0
  85. data/lib/wile/autoloads/receivers.rb +101 -0
  86. data/lib/wile/autoloads/responds.rb +36 -0
  87. data/lib/wile/autoloads/test.rb +78 -0
  88. data/lib/wile/autoloads/thread_pool.rb +64 -0
  89. data/lib/wile/help.rb +41 -0
  90. data/lib/wile/requires.rb +7 -0
  91. data/lib/wile/run.rb +108 -0
  92. data/lib/wile/sysexits.rb +43 -0
  93. data/lib/wile/tasks/build.rb +46 -0
  94. data/lib/wile/tasks/bump.rb +61 -0
  95. data/lib/wile/tasks/compare.rb +139 -0
  96. data/lib/wile/tasks/content.rb +44 -0
  97. data/lib/wile/tasks/cp.rb +52 -0
  98. data/lib/wile/tasks/dependencies.rb +58 -0
  99. data/lib/wile/tasks/dictionary.rb +59 -0
  100. data/lib/wile/tasks/gemcheck.rb +142 -0
  101. data/lib/wile/tasks/gemfile.rb +60 -0
  102. data/lib/wile/tasks/help.rb +29 -0
  103. data/lib/wile/tasks/info.rb +77 -0
  104. data/lib/wile/tasks/install.rb +53 -0
  105. data/lib/wile/tasks/lexicon.rb +59 -0
  106. data/lib/wile/tasks/list.rb +97 -0
  107. data/lib/wile/tasks/methods.rb +154 -0
  108. data/lib/wile/tasks/mkdir.rb +19 -0
  109. data/lib/wile/tasks/note.rb +49 -0
  110. data/lib/wile/tasks/nvim.rb +60 -0
  111. data/lib/wile/tasks/order.rb +93 -0
  112. data/lib/wile/tasks/oscheck.rb +49 -0
  113. data/lib/wile/tasks/publish.rb +67 -0
  114. data/lib/wile/tasks/receivers.rb +34 -0
  115. data/lib/wile/tasks/review.rb +157 -0
  116. data/lib/wile/tasks/ruby.rb +38 -0
  117. data/lib/wile/tasks/tc.rb +114 -0
  118. data/lib/wile/tasks/test.rb +57 -0
  119. data/lib/wile/tasks/todo.rb +55 -0
  120. data/lib/wile/tasks/update.rb +67 -0
  121. data/lib/wile/tasks.rb +34 -0
  122. data/lib/wile/usage.rb +56 -0
  123. data/lib/wile/usage_error.rb +18 -0
  124. data/lib/wile/utilities.rb +283 -0
  125. data/lib/wile/utilities_refinements.rb +41 -0
  126. data/lib/wile/wile_refinements.rb +137 -0
  127. data/lib/wile.rb +39 -0
  128. data/man/wile.1 +1121 -0
  129. data/man/wile.md +786 -0
  130. data/pkg/README.md +3 -0
  131. metadata +399 -0
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ # wile: os `git`
4
+
5
+ # Wile namespace.
6
+ module Wile
7
+ # Info class provides information about the current project.
8
+ # :reek:InstanceVariableAssumption :reek:TooManyInstanceVariables
9
+ # :reek:MissingSafeMethod
10
+ class Info
11
+ using WileRefinements
12
+
13
+ attr_reader :dirname, :cache, :now, :readme,
14
+ :project, :gemspec, :module, :project_rb,
15
+ :username, :email,
16
+ :year, :date
17
+
18
+ def erb_result(filename)
19
+ ERB.new(File.read(filename)).result(binding)
20
+ end
21
+
22
+ def self.reset!
23
+ @info = nil
24
+ end
25
+
26
+ def version
27
+ @version ||= File.read(File.join(@dirname, '.version')).chomp
28
+ end
29
+
30
+ def verify_version!(vrs)
31
+ raise "current version is #{version}, not #{vrs}" unless version == vrs
32
+ end
33
+
34
+ def self.info(...)
35
+ @info ||= new(...)
36
+ end
37
+
38
+ def initialize(dirname: File.expand_path('.'), root: ROOT, now: Time.now)
39
+ @dirname = dirname
40
+ @cache = File.join(root, 'cache')
41
+ @now = now
42
+ set_project!
43
+ end
44
+
45
+ def wileignore
46
+ @wileignore ||= read_rgx('.wileignore')
47
+ end
48
+
49
+ def gemignore
50
+ @gemignore ||= read_rgx('.gemignore')
51
+ end
52
+
53
+ private
54
+
55
+ def read_rgx(filename)
56
+ Regexp.new read(filename).strip, Regexp::EXTENDED
57
+ end
58
+
59
+ def read(filename)
60
+ File.read(File.join(@dirname, filename))
61
+ rescue StandardError
62
+ warn "Warning: using cache #{filename}".yellow
63
+ File.read(File.join(@cache, filename))
64
+ end
65
+
66
+ def set_project!
67
+ set_project_names
68
+ set_git_user
69
+ set_date
70
+ end
71
+
72
+ def set_date
73
+ @year = @now.year
74
+ @date = @now.strftime('%Y-%m-%d')
75
+ end
76
+
77
+ def set_git_user
78
+ @username = `git config user.name 2>/dev/null`.strip
79
+ @username = ENV['USER'].to_s if @username.empty?
80
+ @email = `git config user.email 2>/dev/null`.strip
81
+ end
82
+
83
+ def set_project_names
84
+ @readme = 'README.md'
85
+ @project = File.basename(@dirname)
86
+ @gemspec = "#{@project}.gemspec"
87
+ @module = @project.pascal_case
88
+ @project_rb = "lib/#{@project}.rb"
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ # wile: os `pandoc`
4
+
5
+ # Wile namespace.
6
+ module Wile
7
+ # Generates roff man pages from markdown using pandoc.
8
+ # :reek:MissingSafeMethod
9
+ class Manpage
10
+ def initialize(info = Info.info)
11
+ @info = info
12
+ @project = @info.project
13
+ path = File.join(@info.dirname, 'man', @project)
14
+ @md_path = "#{path}.md"
15
+ @roff_path = "#{path}.1"
16
+ end
17
+
18
+ def exist? = File.file?(@md_path)
19
+
20
+ def update!
21
+ return unless exist?
22
+
23
+ unless Utilities.command_available?('pandoc')
24
+ warn 'Notice: pandoc not found; skipping manpage update.'.yellow
25
+ return
26
+ end
27
+
28
+ Utilities.run('pandoc', *pandoc_args) { |_, msg| raise msg }
29
+ end
30
+
31
+ private
32
+
33
+ def pandoc_args
34
+ ['-s', '-f', 'markdown', '-t', 'man',
35
+ '--shift-heading-level-by=-1',
36
+ '-V', "title=#{@project.upcase}",
37
+ '-V', 'section=1',
38
+ '-V', "date=#{@info.now.strftime('%B %Y')}",
39
+ '-V', "footer=#{@project} #{@info.version}",
40
+ '-V', 'header=User Commands',
41
+ @md_path, '-o', @roff_path]
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Namespace: Wile
4
+ module Wile
5
+ # Categorizes methods
6
+ class Methods
7
+ using WileRefinements
8
+
9
+ # Tracks method definition metadata and file dependencies:
10
+ # * filename: path of the file where the method is defined
11
+ # * dependencies: files containing methods this method invokes
12
+ # * dependants: files containing methods that invoke this method
13
+ # * external: outgoing calls unresolved in filename, stdlib, or Kernel
14
+ MethodEntry = Struct.new(:filename, :dependencies, :dependants,
15
+ :external) do
16
+ def add_dependency(other)
17
+ dependencies << other.filename
18
+ other.dependants << filename
19
+ end
20
+
21
+ def initialize(cdt, name = nil)
22
+ super(cdt.filename, [], [], name ? cdt.external(name) : [])
23
+ return unless name
24
+
25
+ dependencies << filename unless cdt.dependencies(name).empty?
26
+ dependants << filename unless cdt.dependants(name).empty?
27
+ end
28
+ end
29
+
30
+ attr_reader :implicit_methods, :known_constants, :methods,
31
+ :undefined_methods
32
+
33
+ REF = /\w+Refinements::/
34
+ private_constant :REF
35
+
36
+ def initialize(dir = 'lib')
37
+ @methods = {}
38
+ @implicit_methods = Set.new
39
+ @known_constants = Set.new
40
+ @undefined_methods = Set.new
41
+ get_code_data(dir)
42
+ @methods.each { |name, entry| add_undefined_methods(name, entry) }
43
+ end
44
+
45
+ def self.skip_duck?(mth)
46
+ mth.start_with?('*') ||
47
+ (!/^[A-Z]/.match?(mth) && mth.common_ruby_method_name?)
48
+ end
49
+
50
+ def self.skipped_receiver?(mth) = mth.match?(/\A@?(?:options|it|\w+_)#/)
51
+
52
+ private
53
+
54
+ def get_code_data(dir)
55
+ prefix = "#{dir.delete_prefix('./').delete_suffix('/')}/"
56
+ files = Git.files.select { it.start_with?(prefix) && it.end_with?('.rb') }
57
+ files.each { process_file(it) }
58
+ end
59
+
60
+ def process_file(filename, cdt = CodeData.new(filename))
61
+ @known_constants.merge(cdt.constants)
62
+ cdt.names.each { @methods[it] = MethodEntry.new(cdt, it) }
63
+ cdt.attrs.each { @methods[it] = MethodEntry.new(cdt) }
64
+ end
65
+
66
+ def unresolved?(mth, entry)
67
+ !recognized?(mth, entry) && !Methods.skip_duck?(mth) &&
68
+ !Methods.skipped_receiver?(mth)
69
+ end
70
+
71
+ def recognized?(mth, entry)
72
+ # Immediately return false for non ducks:
73
+ return false unless /\A[^A-Z#].*#/.match?(mth)
74
+
75
+ suffix = "##{mth.split('#').last}"
76
+ @methods.select { |key, val| key.end_with?(suffix) && val != entry }
77
+ .each_value { entry.add_dependency(it) }.any?
78
+ end
79
+
80
+ def add_undefined_methods(name, entry)
81
+ entry.external.each do |mth|
82
+ if (selected = selected_method(mth, name))
83
+ entry.add_dependency(@methods[selected])
84
+ elsif implicit_new?(mth)
85
+ @implicit_methods << mth
86
+ elsif !known_constant?(mth, name) && unresolved?(mth, entry)
87
+ @undefined_methods << mth
88
+ end
89
+ end
90
+ end
91
+
92
+ # Checks whether an external call's receiver constant is known and
93
+ # accessible within the caller's (`name`) lexical namespace scope.
94
+ # Matches exact constant paths or constants sharing the caller's scope.
95
+ def known_constant?(mth, name, const = mth.split('.').first)
96
+ return true if @known_constants.include?(const)
97
+
98
+ @known_constants.select { it.end_with?("::#{const}") }
99
+ .any? { name.start_with?(it.delete_suffix("::#{const}")) }
100
+ end
101
+
102
+ # Resolves an external call (`mth`) to a defined method in the caller's
103
+ # (`name`) scope by trying three transformations:
104
+ # 1. `.new` to `#initialize` (instantiations)
105
+ # 2. `#method` to `Kernel#method` (Kernel refinements)
106
+ # 3. `.method` to `#method` (module functions or instance calls)
107
+ # Basically looks for the method definition in the file set or in Kernel.
108
+ def selected_method(mth, name)
109
+ find_method(mth.sub(/\.new$/, '#initialize'), name) ||
110
+ find_method(mth.sub(/^.*#/, 'Kernel#'), name) ||
111
+ find_method(mth.sub('.', '#'), name)
112
+ end
113
+
114
+ # Checks whether an external call is an invocation of `.new` on a known
115
+ # class in the project that lacks an explicit `initialize` method (using
116
+ # Ruby's implicit default constructor).
117
+ def implicit_new?(mth)
118
+ return false unless mth.end_with?('.new')
119
+
120
+ target = mth.delete_suffix('.new')
121
+ # Is this a class defined in our project that has methods?
122
+ @methods.each_key.any? { it.split(/[.#]/).first.end_with?(target) }
123
+ end
124
+
125
+ def find_method(target, name)
126
+ keys = @methods.keys.select { it.end_with?(target) }
127
+ keys.detect { name.start_with?(it.sub(REF, '').delete_suffix(target)) }
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Wile namespace.
4
+ module Wile
5
+ # Orders project files for opening in Neovim.
6
+ class NvimFiles
7
+ REQ_RGX = /'(\w([-\w]*)+)'/
8
+ private_constant :REQ_RGX
9
+
10
+ def initialize(project = Info.info.project)
11
+ @project = project
12
+ end
13
+
14
+ def nvim_files
15
+ lib = nvim_lib_files
16
+ ranks = nvim_ranks(lib)
17
+ more = more_ranks(lib)
18
+ ranks = (ranks - more) + more if more
19
+ ['README.md'] + nvim_bin_files + ranks + (lib - ranks)
20
+ end
21
+
22
+ private
23
+
24
+ def nvim_lib_files
25
+ Git.files.select { it.start_with?('lib/') && it.end_with?('.rb') }
26
+ .sort_by { [it.count('/'), it] }
27
+ end
28
+
29
+ def nvim_bin_files
30
+ return [] unless File.directory?('bin')
31
+
32
+ Git.files.select { it.start_with?('bin/') && File.executable?(it) }.sort
33
+ end
34
+
35
+ def nvim_ranks(lib, prb = "lib/#{@project}.rb")
36
+ rgx = %r{'(#{@project}(/\w[-\w]*)+)'}
37
+ ranks = file_ranks(prb, rgx, /require_relative|auto/)
38
+ ([prb] + (ranks.map { "lib/#{it}.rb" } & lib)).sort_by { it.count('/') }
39
+ end
40
+
41
+ def more_ranks(lib, rqs = "lib/#{@project}/requires.rb")
42
+ return nil unless File.exist?(rqs)
43
+
44
+ (file_ranks(rqs, REQ_RGX).map { "lib/#{@project}/#{it}.rb" } & lib)
45
+ .sort_by { it.count('/') }
46
+ end
47
+
48
+ def file_ranks(filename, rgx, pattern = /require_relative/)
49
+ File.readlines(filename)
50
+ .grep(pattern).grep(rgx)
51
+ .map { it.scan(rgx)[0][0] }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,345 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wile
4
+ # OptionsDictionary holds metadata for allow-listed options and reports
5
+ # on their usage when invoked.
6
+ # rubocop:disable-next Metrics/ClassLength
7
+ class OptionsDictionary
8
+ PATTERNS = {
9
+ 'WORD' => /\A[\w-]+\z/,
10
+ 'CSV' => /\A[\w-]+(,[\w-]+)*\z/,
11
+ 'FILE' => %r{\A(/?[\w.][\w.-]*)+/?\z},
12
+ 'ATTRS' => /\A[a-zA-Z]+(,[a-zA-Z]+)*\z/,
13
+ 'MODE' => /\A[0-7]{3,4}\z/,
14
+ 'INTEGER' => /\A\d+\z/,
15
+ 'DECIMAL' => /\A\d+(\.\d+)?\z/,
16
+ 'PATTERN' => /\A\S+\z/,
17
+ 'USER' => /\A([a-zA-Z_])[\w-]*\z/,
18
+ 'WHEN' => /\A(always|auto|never)\z/,
19
+ 'URL' => %r{\A([a-zA-Z]+://\S+|[\w.-]+@\S+)\z}
20
+ }.freeze
21
+
22
+ OPTIONS = {
23
+ 'all' => {
24
+ desc: 'Apply to all targets',
25
+ type: nil,
26
+ commands: %w[ls du df git]
27
+ },
28
+ 'archive' => {
29
+ desc: 'Archive mode; preserve file attributes and permissions',
30
+ type: nil,
31
+ commands: %w[cp rsync tar]
32
+ },
33
+ 'backup' => {
34
+ desc: 'Make backup before removal or overwrite',
35
+ type: nil,
36
+ commands: %w[cp mv]
37
+ },
38
+ 'batch' => {
39
+ desc: 'Run in non-interactive batch mode',
40
+ type: nil,
41
+ commands: %w[sed make git]
42
+ },
43
+ 'check' => {
44
+ desc: 'Run in check-only mode',
45
+ type: nil,
46
+ commands: %w[sort git]
47
+ },
48
+ 'clean' => {
49
+ desc: 'Remove build artifacts and temporary files',
50
+ type: nil,
51
+ commands: %w[git make]
52
+ },
53
+ 'color' => {
54
+ desc: 'Control colored output (always, auto, never)',
55
+ type: 'WHEN',
56
+ commands: %w[ls grep diff git]
57
+ },
58
+ 'config' => {
59
+ desc: 'Configuration file path',
60
+ type: 'FILE',
61
+ commands: %w[rubocop reek man]
62
+ },
63
+ 'context' => {
64
+ desc: 'Number of lines of context to display',
65
+ type: 'INTEGER',
66
+ commands: %w[grep diff]
67
+ },
68
+ 'count' => {
69
+ desc: 'Print count of matching items instead of contents',
70
+ type: nil,
71
+ commands: %w[grep wc]
72
+ },
73
+ 'delete' => {
74
+ desc: 'Delete extraneous or target files',
75
+ type: nil,
76
+ commands: %w[rsync git]
77
+ },
78
+ 'dereference' => {
79
+ desc: 'Follow symbolic links',
80
+ type: nil,
81
+ commands: %w[ls cp tar]
82
+ },
83
+ 'detailed' => {
84
+ desc: 'Display detailed output',
85
+ type: nil,
86
+ commands: %w[curl rsync tar]
87
+ },
88
+ 'diff' => {
89
+ desc: 'Show differences between files or states',
90
+ type: nil,
91
+ commands: %w[git patch]
92
+ },
93
+ 'directory' => {
94
+ desc: 'Change to directory before operating',
95
+ type: 'FILE',
96
+ commands: %w[tar git make]
97
+ },
98
+ 'dump' => {
99
+ desc: 'Dump internal structure or data',
100
+ type: nil,
101
+ commands: %w[file strings git]
102
+ },
103
+ 'encoding' => {
104
+ desc: 'Character encoding to use',
105
+ type: 'WORD',
106
+ commands: %w[iconv ruby]
107
+ },
108
+ 'exclude' => {
109
+ desc: 'Exclude files or paths matching pattern',
110
+ type: 'PATTERN',
111
+ commands: %w[tar grep rsync]
112
+ },
113
+ 'follow' => {
114
+ desc: 'Output appended data as file grows',
115
+ type: nil,
116
+ commands: %w[tail]
117
+ },
118
+ 'force' => {
119
+ desc: 'Force execution without safety checks',
120
+ type: nil,
121
+ commands: %w[cp mv rm ln git]
122
+ },
123
+ 'format' => {
124
+ desc: 'Output format',
125
+ type: 'WORD',
126
+ commands: %w[rubocop reek cucumber]
127
+ },
128
+ 'git' => {
129
+ desc: 'Operate on git-tracked files',
130
+ type: nil,
131
+ commands: ['"reserved for custom tasks"']
132
+ },
133
+ 'header' => {
134
+ desc: 'Display or include header line',
135
+ type: nil,
136
+ commands: %w[curl ps tar]
137
+ },
138
+ 'help' => {
139
+ desc: 'Show help summary',
140
+ type: nil,
141
+ commands: %w[git reek rubocop]
142
+ },
143
+ 'icase' => {
144
+ desc: 'Ignore case distinctions in patterns or text',
145
+ type: nil,
146
+ commands: %w[grep diff sort]
147
+ },
148
+ 'include' => {
149
+ desc: 'Include only files or paths matching pattern',
150
+ type: 'PATTERN',
151
+ commands: %w[grep rsync]
152
+ },
153
+ 'interactive' => {
154
+ desc: 'Prompt before overwrite or action',
155
+ type: nil,
156
+ commands: %w[cp mv rm git]
157
+ },
158
+ 'interval' => {
159
+ desc: 'Time to wait between repetitions',
160
+ type: 'DECIMAL',
161
+ commands: %w[watch ping]
162
+ },
163
+ 'jobs' => {
164
+ desc: 'Number of concurrent jobs or tasks',
165
+ type: 'INTEGER',
166
+ commands: %w[make ninja xargs]
167
+ },
168
+ 'limit' => {
169
+ desc: 'Limit the number of results or records',
170
+ type: 'INTEGER',
171
+ commands: %w[git sqlite3]
172
+ },
173
+ 'linenumber' => {
174
+ desc: 'Print line number with output lines',
175
+ type: nil,
176
+ commands: %w[grep]
177
+ },
178
+ 'list' => {
179
+ desc: 'List items',
180
+ type: nil,
181
+ commands: %w[reek docker git]
182
+ },
183
+ 'logfile' => {
184
+ desc: 'Path to log file',
185
+ type: 'FILE',
186
+ commands: %w[wget git]
187
+ },
188
+ 'maxdepth' => {
189
+ desc: 'Descend at most INTEGER directory levels',
190
+ type: 'INTEGER',
191
+ commands: %w[find du]
192
+ },
193
+ 'mode' => {
194
+ desc: 'File permission mode (octal or symbolic)',
195
+ type: 'MODE',
196
+ commands: %w[chmod install mkdir]
197
+ },
198
+ 'name' => {
199
+ desc: 'Filter or match by name',
200
+ type: 'WORD',
201
+ commands: %w[find docker]
202
+ },
203
+ 'nocache' => {
204
+ desc: 'Bypass cache and fetch fresh data',
205
+ type: nil,
206
+ commands: %w[curl pacman]
207
+ },
208
+ 'only' => {
209
+ desc: 'Select only specified items',
210
+ type: 'CSV',
211
+ commands: %w[rsync]
212
+ },
213
+ 'output' => {
214
+ desc: 'Write output to file',
215
+ type: 'FILE',
216
+ commands: %w[sort curl wget]
217
+ },
218
+ 'parents' => {
219
+ desc: 'Create intermediate parent directories as needed',
220
+ type: nil,
221
+ commands: %w[mkdir cp]
222
+ },
223
+ 'port' => {
224
+ desc: 'Port number to connect or listen to',
225
+ type: 'INTEGER',
226
+ commands: %w[curl ssh]
227
+ },
228
+ 'preserve' => {
229
+ desc: 'Preserve specified file attributes',
230
+ type: 'ATTRS',
231
+ commands: %w[cp]
232
+ },
233
+ 'quiet' => {
234
+ desc: 'Suppress non-essential output',
235
+ type: nil,
236
+ commands: %w[grep curl rsync]
237
+ },
238
+ 'raw' => {
239
+ desc: 'Raw / unformatted output',
240
+ type: nil,
241
+ commands: %w[netcat curl git]
242
+ },
243
+ 'readable' => {
244
+ desc: 'Print human readable output',
245
+ type: nil,
246
+ commands: %w[ls du df]
247
+ },
248
+ 'recursive' => {
249
+ desc: 'Operate recursively on directories',
250
+ type: nil,
251
+ commands: %w[cp rm rsync grep]
252
+ },
253
+ 'remote' => {
254
+ desc: 'Remote repository or server address',
255
+ type: 'URL',
256
+ commands: %w[git rsync]
257
+ },
258
+ 'reverse' => {
259
+ desc: 'Reverse sorting order of results',
260
+ type: nil,
261
+ commands: %w[ls sort]
262
+ },
263
+ 'simulate' => {
264
+ desc: 'Simulate execution without making changes',
265
+ type: nil,
266
+ commands: %w[rsync git make]
267
+ },
268
+ 'sort' => {
269
+ desc: 'Sort output by specified key or field',
270
+ type: 'WORD',
271
+ commands: %w[ls sort ps]
272
+ },
273
+ 'status' => {
274
+ desc: 'Display operational status or summary',
275
+ type: nil,
276
+ commands: %w[git service docker]
277
+ },
278
+ 'strict' => {
279
+ desc: 'Enable strict mode',
280
+ type: nil,
281
+ commands: %w[perl]
282
+ },
283
+ 'sync' => {
284
+ desc: 'Synchronize data to storage before exiting',
285
+ type: nil,
286
+ commands: %w[dd cp]
287
+ },
288
+ 'tag' => {
289
+ desc: 'Tag name or label to apply or filter by',
290
+ type: 'WORD',
291
+ commands: %w[git docker]
292
+ },
293
+ 'target' => {
294
+ desc: 'Target file, directory, or architecture',
295
+ type: 'FILE',
296
+ commands: %w[cp make]
297
+ },
298
+ 'timeout' => {
299
+ desc: 'Maximum time to wait before timing out',
300
+ type: 'DECIMAL',
301
+ commands: %w[curl timeout ssh]
302
+ },
303
+ 'trace' => {
304
+ desc: 'Trace execution',
305
+ type: nil,
306
+ commands: %w[strace ruby rake]
307
+ },
308
+ 'user' => {
309
+ desc: 'Run as or filter by user',
310
+ type: 'USER',
311
+ commands: %w[curl chown docker ps]
312
+ },
313
+ 'version' => {
314
+ desc: 'Show version number',
315
+ type: nil,
316
+ commands: %w[git diff reek rubocop]
317
+ },
318
+ 'yes' => {
319
+ desc: 'Assume yes to confirmation prompts',
320
+ type: nil,
321
+ commands: %w[apt-get yum]
322
+ }
323
+ }.freeze
324
+
325
+ def initialize(options)
326
+ options.to_h.each do |key, value|
327
+ next unless (entry = OPTIONS[key.to_s])
328
+
329
+ report(key, value, entry)
330
+ end
331
+ end
332
+
333
+ private
334
+
335
+ def report(key, value, entry)
336
+ type, desc, commands = entry.values_at(:type, :desc, :commands)
337
+ puts [
338
+ type ? "--#{key}=#{value}" : "--#{key}",
339
+ " Description: #{desc}",
340
+ (" Pattern: #{type} (/#{PATTERNS[type].source}/)" if type),
341
+ " Commands: #{commands.join(', ')}"
342
+ ].compact
343
+ end
344
+ end
345
+ end