thor_nested_subcommand 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f44a5dd3d7c41a69266bd8b5f39714b31a1deb9dc1950d37483096a569d5f557
4
+ data.tar.gz: 402eb19a513f126c1d98ec6b551319400c5113114319274a278e00f0bb5436a4
5
+ SHA512:
6
+ metadata.gz: f30c556d8f3d6a5047c5f27b14f4bfeaa327d6a39f2401289c0a573a5efea58a29f699aec332c2809b7a77d11129ca4f24fb379d1a625bce99d37680ea34381e
7
+ data.tar.gz: b7ba58c782711544b16a4842176d91b018b3682c992538225f776a767ad68f487493bd15168af8e670bdb718460e634acec2b757861884804840f57dd0571bab
data/.reek.yml ADDED
@@ -0,0 +1,20 @@
1
+ exclude_paths:
2
+ - vendor
3
+ - spec
4
+ - scratch*.rb
5
+ - snippets*.rb
6
+ detectors:
7
+ # TooManyInstanceVariables:
8
+ # exclude:
9
+ # - "Class1"
10
+ # - "Class2"
11
+ # private methods do not have to depend on instance state
12
+ # https://github.com/troessner/reek/blob/master/docs/Utility-Function.md
13
+ UtilityFunction:
14
+ public_methods_only: true
15
+ # Check for variable name that doesn't communicate its intent well enough
16
+ # https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
17
+ UncommunicativeVariableName:
18
+ accept:
19
+ - /^_$/
20
+ - /^e$/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,187 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 3.0
7
+ NewCops: enable
8
+ Exclude:
9
+ - '.git/**/*'
10
+ - '.idea/**/*'
11
+ - 'init/*'
12
+ - 'Rakefile'
13
+ - 'vendor/**/*'
14
+ - 'scratch*.rb'
15
+ - 'snippets*.rb'
16
+
17
+ # Align the elements of a hash literal if they span more than one line.
18
+ Layout/HashAlignment:
19
+ EnforcedLastArgumentHashStyle: always_ignore
20
+
21
+ # Alignment of parameters in multi-line method definition.
22
+ # The `with_fixed_indentation` style aligns the following lines with one
23
+ # level of indentation relative to the start of the line with the method
24
+ # definition.
25
+ #
26
+ # def my_method(a,
27
+ # b)
28
+ Layout/ParameterAlignment:
29
+ EnforcedStyle: with_fixed_indentation
30
+
31
+ # Alignment of parameters in multi-line method call.
32
+ # The `with_fixed_indentation` style aligns the following lines with one
33
+ # level of indentation relative to the start of the line with the method call.
34
+ #
35
+ # my_method(a,
36
+ # b)
37
+ Layout/ArgumentAlignment:
38
+ EnforcedStyle: with_fixed_indentation
39
+
40
+ # a = case n
41
+ # when 0
42
+ # x * 2
43
+ # else
44
+ # y / 3
45
+ # end
46
+ Layout/CaseIndentation:
47
+ EnforcedStyle: end
48
+
49
+ # Enforces a configured order of definitions within a class body
50
+ Layout/ClassStructure:
51
+ Enabled: true
52
+
53
+ # Align `end` with the matching keyword or starting expression except for
54
+ # assignments, where it should be aligned with the LHS.
55
+ Layout/EndAlignment:
56
+ EnforcedStyleAlignWith: variable
57
+ AutoCorrect: true
58
+
59
+ # The `consistent` style enforces that the first element in an array
60
+ # literal where the opening bracket and the first element are on
61
+ # seprate lines is indented the same as an array literal which is not
62
+ # defined inside a method call.
63
+ Layout/FirstArrayElementIndentation:
64
+ EnforcedStyle: consistent
65
+
66
+ # The `consistent` style enforces that the first key in a hash
67
+ # literal where the opening brace and the first key are on
68
+ # seprate lines is indented the same as a hash literal which is not
69
+ # defined inside a method call.
70
+ Layout/FirstHashElementIndentation:
71
+ EnforcedStyle: consistent
72
+
73
+ # Indent multi-line methods instead of aligning with periods
74
+ Layout/MultilineMethodCallIndentation:
75
+ EnforcedStyle: indented
76
+
77
+ # Allow `debug` in tasks for now
78
+ Lint/Debugger:
79
+ Exclude:
80
+ - 'RakeFile'
81
+
82
+ # A calculated magnitude based on number of assignments, branches, and
83
+ # conditions.
84
+ # NOTE: This is temporarily disabled until we can eliminate existing Rubocop
85
+ # complaints
86
+ Metrics/AbcSize:
87
+ Enabled: false
88
+
89
+ # Avoid long blocks with many lines.
90
+ Metrics/BlockLength:
91
+ Exclude:
92
+ - 'RakeFile'
93
+ - 'db/seeds.rb'
94
+ - 'spec/**/*.rb'
95
+
96
+ # Avoid classes longer than 100 lines of code.
97
+ # NOTE: This is temporarily disabled until we can eliminate existing Rubocop
98
+ # complaints
99
+ Metrics/ClassLength:
100
+ Max: 200
101
+ Exclude:
102
+ - 'spec/**/*.rb'
103
+
104
+ # A complexity metric that is strongly correlated to the number of test cases
105
+ # needed to validate a method.
106
+ Metrics/CyclomaticComplexity:
107
+ Max: 9
108
+
109
+ # Limit lines to 80 characters
110
+ Layout/LineLength:
111
+ Exclude:
112
+ - 'RakeFile'
113
+ - 'spec/**/*.rb'
114
+
115
+ # Avoid methods longer than 15 lines of code.
116
+ Metrics/MethodLength:
117
+ Max: 20
118
+ AllowedMethods:
119
+ - swagger_path
120
+ - operation
121
+
122
+
123
+ # A complexity metric geared towards measuring complexity for a human reader.
124
+ Metrics/PerceivedComplexity:
125
+ Max: 10
126
+
127
+ # Naming/FileName:
128
+ # Exclude:
129
+ # - 'lib/file.rb'
130
+
131
+ # Allow `downcase == ` instead of forcing `casecmp`
132
+ Performance/Casecmp:
133
+ Enabled: false
134
+
135
+ # Require children definitions to be nested or compact in classes and modules
136
+ Style/ClassAndModuleChildren:
137
+ Enabled: false
138
+
139
+ # Document classes and non-namespace modules.
140
+ # (Disabled for now, may revisit later)
141
+ Style/Documentation:
142
+ Enabled: false
143
+
144
+ # Checks the formatting of empty method definitions.
145
+ Style/EmptyMethod:
146
+ EnforcedStyle: expanded
147
+
148
+ # Add the frozen_string_literal comment to the top of files to help transition
149
+ # to frozen string literals by default.
150
+ Style/FrozenStringLiteralComment:
151
+ EnforcedStyle: always
152
+
153
+ # Check for conditionals that can be replaced with guard clauses
154
+ Style/GuardClause:
155
+ Enabled: false
156
+
157
+ Style/MixinUsage:
158
+ Exclude:
159
+ - 'RakeFile'
160
+
161
+ # Avoid multi-line method signatures.
162
+ Style/MultilineMethodSignature:
163
+ Enabled: true
164
+
165
+ # Don't use option hashes when you can use keyword arguments.
166
+ Style/OptionHash:
167
+ Enabled: true
168
+
169
+ # Use return instead of return nil.
170
+ Style/ReturnNil:
171
+ Enabled: true
172
+
173
+ # Allow code like `return x, y` as it's occasionally handy.
174
+ Style/RedundantReturn:
175
+ AllowMultipleReturnValues: true
176
+
177
+ # Prefer symbols instead of strings as hash keys.
178
+ Style/StringHashKeys:
179
+ Enabled: true
180
+
181
+ # Checks if configured preferred methods are used over non-preferred.
182
+ Style/StringMethods:
183
+ Enabled: true
184
+
185
+ # Checks for use of parentheses around ternary conditions.
186
+ Style/TernaryParentheses:
187
+ EnforcedStyle: require_parentheses_when_complex
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [1.0.0] - 2022-10-06
2
+
3
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at web.gma@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in thor_nested_subcommand.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 0.81.0'
11
+
12
+ gem 'pry-byebug', '~> 3.9'
13
+ gem 'reek', '~> 6.1', '>= 6.1.1'
14
+ gem 'simplecov', '~> 0.21.2'
15
+ gem 'thor', '~> 1.2', '>= 1.2.1'
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ thor_nested_subcommand (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (11.1.3)
11
+ coderay (1.1.3)
12
+ diff-lcs (1.5.0)
13
+ docile (1.4.0)
14
+ jaro_winkler (1.5.4)
15
+ kwalify (0.7.2)
16
+ method_source (1.0.0)
17
+ parallel (1.22.1)
18
+ parser (3.1.2.1)
19
+ ast (~> 2.4.1)
20
+ pry (0.14.1)
21
+ coderay (~> 1.1)
22
+ method_source (~> 1.0)
23
+ pry-byebug (3.10.1)
24
+ byebug (~> 11.0)
25
+ pry (>= 0.13, < 0.15)
26
+ rainbow (3.1.1)
27
+ rake (13.0.6)
28
+ reek (6.1.1)
29
+ kwalify (~> 0.7.0)
30
+ parser (~> 3.1.0)
31
+ rainbow (>= 2.0, < 4.0)
32
+ rexml (3.2.5)
33
+ rspec (3.11.0)
34
+ rspec-core (~> 3.11.0)
35
+ rspec-expectations (~> 3.11.0)
36
+ rspec-mocks (~> 3.11.0)
37
+ rspec-core (3.11.0)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-expectations (3.11.1)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-mocks (3.11.1)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-support (3.11.1)
46
+ rubocop (0.81.0)
47
+ jaro_winkler (~> 1.5.1)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.7.0.1)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ rexml
52
+ ruby-progressbar (~> 1.7)
53
+ unicode-display_width (>= 1.4.0, < 2.0)
54
+ ruby-progressbar (1.11.0)
55
+ simplecov (0.21.2)
56
+ docile (~> 1.1)
57
+ simplecov-html (~> 0.11)
58
+ simplecov_json_formatter (~> 0.1)
59
+ simplecov-html (0.12.3)
60
+ simplecov_json_formatter (0.1.4)
61
+ thor (1.2.1)
62
+ unicode-display_width (1.8.0)
63
+
64
+ PLATFORMS
65
+ x86_64-darwin-19
66
+
67
+ DEPENDENCIES
68
+ pry-byebug (~> 3.9)
69
+ rake (~> 13.0)
70
+ reek (~> 6.1, >= 6.1.1)
71
+ rspec (~> 3.0)
72
+ rubocop (~> 0.81.0)
73
+ simplecov (~> 0.21.2)
74
+ thor (~> 1.2, >= 1.2.1)
75
+ thor_nested_subcommand!
76
+
77
+ BUNDLED WITH
78
+ 2.3.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 gangelo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # ThorNestedSubcommand
2
+
3
+ `ThorNestedSubcommand` is a Ruby gem that provides a workaround for the [Thor gem](https://rubygems.org/gems/thor) bug that displays nested subcommand help incorrectly. Simply include the `ThorNestedSubcommand` module in your Thor nested subcommand, and provide a simple class method to return what Thor help shoul be displaying, and that's it.
4
+
5
+ ## Usage
6
+
7
+ First, follow instructions for [installation](#installation).
8
+
9
+ Secondly, do the following in your Thor `subcommand`:
10
+ * include the `ThorNestedSubcommand`.
11
+ * Add a `.base_name` class method and return the base name for the nested `subcommand` you need Thor help to display.
12
+
13
+ For example:
14
+
15
+ ```ruby
16
+ require 'thor'
17
+ require 'thor_nested_subcommand'
18
+
19
+ class Command < ::Thor
20
+ desc 'sub_command SUBCOMMAND', 'sub command'
21
+ subcommand :sub_command, SubCommand
22
+ end
23
+
24
+ class SubCommand < ::Thor
25
+ desc 'nested_sub_command SUBCOMMAND', 'nested sub command'
26
+ subcommand :nested_sub_command, NestedSubCommand
27
+ end
28
+
29
+ # Thor help breaks because this is a nested subcommand.
30
+ class NestedSubCommand < ::Thor
31
+ # Include this:
32
+ include ThorNestedSubcommand
33
+
34
+ class << self
35
+ # Add this:
36
+ def base_usage
37
+ # Return what Thor shoud be displaying for your nested subcommand:
38
+ 'sub_command nested_sub_command'
39
+ end
40
+ end
41
+
42
+ desc 'test', 'test the command'
43
+ def test
44
+ puts 'test'
45
+ end
46
+ end
47
+ ```
48
+
49
+ That's it. Disaster averted:
50
+
51
+ ```shell
52
+ $ command sub_command help nested_sub_command
53
+ > Commands:
54
+ > command sub_command nested_sub_command help [COMMAND] # Describe subcommands or one specific subcommand
55
+ > command sub_command nested_sub_command test # test sub sub command
56
+ ```
57
+
58
+ ## Installation
59
+
60
+ Add this line to your application's Gemfile:
61
+
62
+ ```ruby
63
+ gem 'thor_nested_subcommand'
64
+ ```
65
+
66
+ And then execute:
67
+
68
+ $ bundle install
69
+
70
+ Or install it yourself as:
71
+
72
+ $ gem install thor_nested_subcommand
73
+
74
+ ## Development
75
+
76
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
77
+
78
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
79
+
80
+ ## Contributing
81
+
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/thor_nested_subcommand. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/thor_nested_subcommand/blob/main/CODE_OF_CONDUCT.md).
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
87
+
88
+ ## Code of Conduct
89
+
90
+ Everyone interacting in the ThorNestedSubcommand project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/thor_nested_subcommand/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'thor'
5
+ require 'bundler/setup'
6
+ require 'thor_nested_subcommand'
7
+
8
+ require 'pry-byebug'
9
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ThorNestedSubcommand
4
+ VERSION = '1.0.0'
5
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'thor_nested_subcommand/version'
4
+
5
+ # The main namespace for the thor_nested_subcommand gem.
6
+ module ThorNestedSubcommand
7
+ # This module fixes a bug in Thor that prohibits help for nested
8
+ # subcommands from displaying help properly. Nested subcommands fail
9
+ # to display their subcommand ancestor command name. This fixes that
10
+ # bug.
11
+ class << self
12
+ def included(base)
13
+ base.extend ClassMethods
14
+ end
15
+ end
16
+
17
+ module ClassMethods
18
+ def base_usage
19
+ raise NotImplementedError
20
+ end
21
+
22
+ # Thor override
23
+ # rubocop:disable Style/OptionHash
24
+ def desc(usage, description, options = {})
25
+ super "#{base_usage} #{usage} ", description, options
26
+ end
27
+ # rubocop:enable Style/OptionHash
28
+
29
+ # Thor override
30
+ # rubocop:disable Style/GlobalVars
31
+ # rubocop:disable Lint/UnusedMethodArgument
32
+ # rubocop:disable Style/OptionalBooleanParameter
33
+ def banner(command, namespace = nil, subcommand = false)
34
+ command.formatted_usage(self, $thor_runner, subcommand).split("\n").map do |_formatted_usage|
35
+ "#{basename} #{command.usage}"
36
+ end.join("\n")
37
+ end
38
+ # rubocop:enable Style/GlobalVars
39
+ # rubocop:enable Lint/UnusedMethodArgument
40
+ # rubocop:enable Style/OptionalBooleanParameter
41
+ end
42
+ end
data/readme.txt ADDED
File without changes
data/scratch.rb ADDED
File without changes
@@ -0,0 +1,4 @@
1
+ module ThorNestedSubcommand
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/snippets.rb ADDED
File without changes
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": "."
5
+ }
6
+ ],
7
+ "settings": {}
8
+ }
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/thor_nested_subcommand/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'thor_nested_subcommand'
7
+ spec.version = ThorNestedSubcommand::VERSION
8
+ spec.authors = ['Gene M. Angelo, Jr.']
9
+ spec.email = ['public.gma@gmail.com']
10
+
11
+ spec.summary = 'A workaround for the Thor gem bug that displays nested subcommand help incorrectly.'
12
+ spec.description = <<-DESC
13
+ `ThorNestedSubcommand` is a Ruby gem that provides a workaround for the
14
+ Thor gem (https://rubygems.org/gems/thor) bug that displays nested subcommand
15
+ help incorrectly. Simply include the `ThorNestedSubcommand` module in your Thor
16
+ nested subcommand, and provide a simple class method to return what Thor help
17
+ should be displaying, and that's it.
18
+ DESC
19
+ spec.homepage = 'https://github.com/gangelo/thor_nested_subcommand'
20
+ spec.license = 'MIT'
21
+ spec.required_ruby_version = '>= 3.0.1'
22
+
23
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
24
+
25
+ spec.metadata['homepage_uri'] = spec.homepage
26
+ spec.metadata['source_code_uri'] = spec.homepage
27
+ spec.metadata['changelog_uri'] = 'https://github.com/gangelo/thor_nested_subcommand/blob/main/CHANGELOG.md'
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
+ `git ls-files -z`.split("\x0").reject do |f|
33
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
34
+ end
35
+ end
36
+ spec.bindir = 'exe'
37
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ['lib']
39
+
40
+ # Uncomment to register a new dependency of your gem
41
+ # spec.add_dependency "example-gem", "~> 1.0"
42
+
43
+ # For more information and examples about making a new gem, checkout our
44
+ # guide at: https://bundler.io/guides/creating_gem.html
45
+ spec.metadata['rubygems_mfa_required'] = 'true'
46
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thor_nested_subcommand
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gene M. Angelo, Jr.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ `ThorNestedSubcommand` is a Ruby gem that provides a workaround for the
15
+ Thor gem (https://rubygems.org/gems/thor) bug that displays nested subcommand
16
+ help incorrectly. Simply include the `ThorNestedSubcommand` module in your Thor
17
+ nested subcommand, and provide a simple class method to return what Thor help
18
+ should be displaying, and that's it.
19
+ email:
20
+ - public.gma@gmail.com
21
+ executables: []
22
+ extensions: []
23
+ extra_rdoc_files: []
24
+ files:
25
+ - ".reek.yml"
26
+ - ".rspec"
27
+ - ".rubocop.yml"
28
+ - ".ruby-version"
29
+ - CHANGELOG.md
30
+ - CODE_OF_CONDUCT.md
31
+ - Gemfile
32
+ - Gemfile.lock
33
+ - LICENSE.txt
34
+ - README.md
35
+ - Rakefile
36
+ - bin/console
37
+ - bin/setup
38
+ - lib/thor_nested_subcommand.rb
39
+ - lib/thor_nested_subcommand/version.rb
40
+ - readme.txt
41
+ - scratch.rb
42
+ - sig/thor_nested_subcommand.rbs
43
+ - snippets.rb
44
+ - thor_nested_subcommand.code-workspace
45
+ - thor_nested_subcommand.gemspec
46
+ homepage: https://github.com/gangelo/thor_nested_subcommand
47
+ licenses:
48
+ - MIT
49
+ metadata:
50
+ homepage_uri: https://github.com/gangelo/thor_nested_subcommand
51
+ source_code_uri: https://github.com/gangelo/thor_nested_subcommand
52
+ changelog_uri: https://github.com/gangelo/thor_nested_subcommand/blob/main/CHANGELOG.md
53
+ rubygems_mfa_required: 'true'
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.0.1
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.3.22
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: A workaround for the Thor gem bug that displays nested subcommand help incorrectly.
73
+ test_files: []