claide 1.0.0 → 1.1.0
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 +5 -5
- data/.github/workflows/ci.yml +45 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_cocoapods.yml +37 -19
- data/.rubocop_todo.yml +2 -2
- data/CHANGELOG.md +46 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +26 -21
- data/{README.markdown → README.md} +15 -18
- data/Rakefile +1 -1
- data/claide.gemspec +3 -1
- data/lib/claide/argv.rb +14 -14
- data/lib/claide/command/plugin_manager.rb +35 -20
- data/lib/claide/command.rb +14 -4
- data/lib/claide/gem_version.rb +7 -0
- data/lib/claide/informative_error.rb +1 -1
- data/lib/claide.rb +0 -6
- metadata +11 -11
- data/.travis.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ce49a146b536fe694eeb4e10a947a0aad328e0adf3b577e6e2892a2d5d731797
|
4
|
+
data.tar.gz: 70621a02b23f1180c3fc17de21facb3d58832588e30059e1e430b64bed0baaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd15350e4cf9889e67194308993ce16fa5bc9a1d783dd13d4f8a215b4e2bda0535b97ac21092ea828bf07911deb4d0a7a958d981fea38969a47d0e6d6c984908
|
7
|
+
data.tar.gz: 48366facfd7cb166c14ceddc4c7918e040de1e8a0a89401ef94544fd35d7c22d1045471c7512c6f1dea36cb6b37acde286adbb1b7787edf8aab2f02c1b2da76d
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
- '*-stable'
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
ci:
|
13
|
+
name: Ruby ${{ matrix.ruby.name }}
|
14
|
+
|
15
|
+
runs-on: ubuntu-20.04
|
16
|
+
|
17
|
+
strategy:
|
18
|
+
fail-fast: false
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
ruby:
|
22
|
+
- { name: "2.3", value: 2.3.8 }
|
23
|
+
- { name: "2.4", value: 2.4.10 }
|
24
|
+
- { name: "2.5", value: 2.5.9 }
|
25
|
+
- { name: "2.6", value: 2.6.9 }
|
26
|
+
- { name: "2.7", value: 2.7.5 }
|
27
|
+
- { name: "3.0", value: 3.0.3 }
|
28
|
+
- { name: "3.1", value: 3.1.0 }
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
|
33
|
+
- name: Setup ruby
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby.value }}
|
37
|
+
bundler-cache: true
|
38
|
+
|
39
|
+
- name: Run Test
|
40
|
+
run: bundle exec rake spec
|
41
|
+
|
42
|
+
- name: Test & publish code coverage
|
43
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
44
|
+
env:
|
45
|
+
CC_TEST_REPORTER_ID: 46c8b29dd6711f35704e7c5a541486cbbf2cff8b2df8ce755bfc09917d3c1cbb
|
data/.rubocop.yml
CHANGED
data/.rubocop_cocoapods.yml
CHANGED
@@ -9,33 +9,33 @@ AllCops:
|
|
9
9
|
|
10
10
|
# At the moment not ready to be used
|
11
11
|
# https://github.com/bbatsov/rubocop/issues/947
|
12
|
-
Documentation:
|
12
|
+
Style/Documentation:
|
13
13
|
Enabled: false
|
14
14
|
|
15
15
|
#- CocoaPods -----------------------------------------------------------------#
|
16
16
|
|
17
17
|
# We adopted raise instead of fail.
|
18
|
-
SignalException:
|
18
|
+
Style/SignalException:
|
19
19
|
EnforcedStyle: only_raise
|
20
20
|
|
21
21
|
# They are idiomatic
|
22
|
-
AssignmentInCondition:
|
22
|
+
Lint/AssignmentInCondition:
|
23
23
|
Enabled: false
|
24
24
|
|
25
25
|
# Allow backticks
|
26
|
-
AsciiComments:
|
26
|
+
Style/AsciiComments:
|
27
27
|
Enabled: false
|
28
28
|
|
29
29
|
# Indentation clarifies logic branches in implementations
|
30
|
-
IfUnlessModifier:
|
30
|
+
Style/IfUnlessModifier:
|
31
31
|
Enabled: false
|
32
32
|
|
33
33
|
# No enforced convention here.
|
34
|
-
SingleLineBlockParams:
|
34
|
+
Style/SingleLineBlockParams:
|
35
35
|
Enabled: false
|
36
36
|
|
37
37
|
# We only add the comment when needed.
|
38
|
-
Encoding:
|
38
|
+
Style/Encoding:
|
39
39
|
Enabled: false
|
40
40
|
|
41
41
|
# Having these make it easier to *not* forget to add one when adding a new
|
@@ -43,18 +43,21 @@ Encoding:
|
|
43
43
|
Style/TrailingCommaInArguments:
|
44
44
|
EnforcedStyleForMultiline: comma
|
45
45
|
|
46
|
-
Style/
|
46
|
+
Style/TrailingCommaInArrayLiteral:
|
47
47
|
EnforcedStyleForMultiline: comma
|
48
48
|
|
49
|
-
Style/
|
49
|
+
Style/TrailingCommaInHashLiteral:
|
50
|
+
EnforcedStyleForMultiline: comma
|
51
|
+
|
52
|
+
Layout/MultilineOperationIndentation:
|
50
53
|
EnforcedStyle: indented
|
51
54
|
|
52
55
|
# Clashes with CLAide Command#validate!
|
53
|
-
GuardClause:
|
56
|
+
Style/GuardClause:
|
54
57
|
Enabled: false
|
55
58
|
|
56
59
|
# Not always desirable: lib/claide/command/plugins_helper.rb:12:15
|
57
|
-
Next:
|
60
|
+
Style/Next:
|
58
61
|
Enabled: false
|
59
62
|
|
60
63
|
# Arbitrary max lengths for classes simply do not work and enabling this will
|
@@ -93,16 +96,16 @@ Metrics/PerceivedComplexity:
|
|
93
96
|
|
94
97
|
#- CocoaPods support for Ruby 1.8.7 ------------------------------------------#
|
95
98
|
|
96
|
-
HashSyntax:
|
99
|
+
Style/HashSyntax:
|
97
100
|
EnforcedStyle: hash_rockets
|
98
101
|
|
99
|
-
Lambda:
|
102
|
+
Style/Lambda:
|
100
103
|
Enabled: false
|
101
104
|
|
102
|
-
DotPosition:
|
105
|
+
Layout/DotPosition:
|
103
106
|
EnforcedStyle: trailing
|
104
107
|
|
105
|
-
EachWithObject:
|
108
|
+
Style/EachWithObject:
|
106
109
|
Enabled: false
|
107
110
|
|
108
111
|
Style/SpecialGlobalVars:
|
@@ -111,7 +114,7 @@ Style/SpecialGlobalVars:
|
|
111
114
|
#- CocoaPods specs -----------------------------------------------------------#
|
112
115
|
|
113
116
|
# Allow for `should.match /regexp/`.
|
114
|
-
AmbiguousRegexpLiteral:
|
117
|
+
Lint/AmbiguousRegexpLiteral:
|
115
118
|
Exclude:
|
116
119
|
- spec/**/*
|
117
120
|
|
@@ -120,14 +123,29 @@ Performance/RedundantMatch:
|
|
120
123
|
- spec/**/*
|
121
124
|
|
122
125
|
# Allow `object.should == object` syntax.
|
123
|
-
Void:
|
126
|
+
Lint/Void:
|
124
127
|
Exclude:
|
125
128
|
- spec/**/*
|
126
129
|
|
127
|
-
ClassAndModuleChildren:
|
130
|
+
Style/ClassAndModuleChildren:
|
128
131
|
Exclude:
|
129
132
|
- spec/**/*
|
130
133
|
|
131
|
-
UselessComparison:
|
134
|
+
Lint/UselessComparison:
|
132
135
|
Exclude:
|
133
136
|
- spec/**/*
|
137
|
+
|
138
|
+
Lint/RaiseException:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Lint/StructNewOverride:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
Style/HashEachMethods:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
Style/HashTransformKeys:
|
148
|
+
Enabled: false
|
149
|
+
|
150
|
+
Style/HashTransformValues:
|
151
|
+
Enabled: false
|
data/.rubocop_todo.yml
CHANGED
@@ -13,7 +13,7 @@ Lint/IneffectiveAccessModifier:
|
|
13
13
|
|
14
14
|
# Offense count: 1
|
15
15
|
# Cop supports --auto-correct.
|
16
|
-
Lint/
|
16
|
+
Lint/RedundantCopDisableDirective:
|
17
17
|
Exclude:
|
18
18
|
- 'spec/command/banner_spec.rb'
|
19
19
|
|
@@ -65,6 +65,6 @@ Style/ParallelAssignment:
|
|
65
65
|
|
66
66
|
# Offense count: 1
|
67
67
|
# Cop supports --auto-correct.
|
68
|
-
Style/
|
68
|
+
Style/RedundantInterpolation:
|
69
69
|
Exclude:
|
70
70
|
- 'lib/claide/command/argument_suggester.rb'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,51 @@
|
|
1
1
|
# CLAide Changelog
|
2
2
|
|
3
|
+
## 1.1.0 (2022-01-12)
|
4
|
+
|
5
|
+
##### Enhancements
|
6
|
+
|
7
|
+
* None.
|
8
|
+
|
9
|
+
##### Bug Fixes
|
10
|
+
|
11
|
+
* None.
|
12
|
+
|
13
|
+
|
14
|
+
## 1.0.3 (2019-08-02)
|
15
|
+
|
16
|
+
##### Enhancements
|
17
|
+
|
18
|
+
* None.
|
19
|
+
|
20
|
+
##### Bug Fixes
|
21
|
+
|
22
|
+
* Correctly handle `--help` flags when using `argv.remainder!` after initialization
|
23
|
+
[Eric Amorde](https://github.com/amorde),
|
24
|
+
[tripleCC](https://github.com/tripleCC)
|
25
|
+
[#87](https://github.com/CocoaPods/CLAide/pull/87)
|
26
|
+
|
27
|
+
|
28
|
+
## 1.0.2 (2017-06-06)
|
29
|
+
|
30
|
+
##### Enhancements
|
31
|
+
|
32
|
+
* None.
|
33
|
+
|
34
|
+
##### Bug Fixes
|
35
|
+
|
36
|
+
* Avoid a method redefinition warning when requiring `claide`.
|
37
|
+
[Samuel Giddins](https://github.com/segiddins)
|
38
|
+
|
39
|
+
|
40
|
+
## 1.0.1 (2016-10-10)
|
41
|
+
|
42
|
+
##### Bug Fixes
|
43
|
+
|
44
|
+
* Adds a fix for older versions of Rubygems when CLAide crashes.
|
45
|
+
[Samuel Giddins](https://github.com/segiddins)
|
46
|
+
[#73](https://github.com/CocoaPods/CLAide/issues/73)
|
47
|
+
|
48
|
+
|
3
49
|
## 1.0.0 (2016-05-10)
|
4
50
|
|
5
51
|
##### Enhancements
|
data/Gemfile
CHANGED
@@ -11,13 +11,12 @@ end
|
|
11
11
|
|
12
12
|
group :spec do
|
13
13
|
gem 'bacon'
|
14
|
-
gem 'json'
|
14
|
+
gem 'json', '< 3'
|
15
15
|
gem 'mocha-on-bacon'
|
16
16
|
gem 'prettybacon'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
gem 'parallel', '<= 1.19.2'
|
19
|
+
gem 'rubocop', '<= 0.81.0'
|
20
|
+
gem 'rubocop-performance', '<= 1.5.2', :require => nil
|
21
|
+
gem 'simplecov'
|
23
22
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
claide (1.
|
4
|
+
claide (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.2
|
9
|
+
ast (2.4.2)
|
10
10
|
bacon (1.2.0)
|
11
|
-
codeclimate-test-reporter (0.4.1)
|
12
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
13
11
|
colored (1.2)
|
14
12
|
docile (1.1.5)
|
15
|
-
ffi (1.
|
16
|
-
|
13
|
+
ffi (1.14.2)
|
14
|
+
jaro_winkler (1.5.4)
|
15
|
+
json (2.5.1)
|
17
16
|
kicker (3.0.0)
|
18
17
|
listen (~> 1.3.0)
|
19
18
|
notify (~> 0.5.2)
|
@@ -28,31 +27,36 @@ GEM
|
|
28
27
|
mocha (>= 0.13.0)
|
29
28
|
multi_json (1.10.1)
|
30
29
|
notify (0.5.2)
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
parallel (1.19.2)
|
31
|
+
parser (3.1.0.0)
|
32
|
+
ast (~> 2.4.1)
|
34
33
|
prettybacon (0.0.2)
|
35
34
|
bacon (~> 1.2)
|
36
|
-
rainbow (
|
35
|
+
rainbow (3.0.0)
|
37
36
|
rake (10.3.2)
|
38
37
|
rb-fsevent (0.9.4)
|
39
38
|
rb-inotify (0.9.5)
|
40
39
|
ffi (>= 0.5.0)
|
41
40
|
rb-kqueue (0.2.3)
|
42
41
|
ffi (>= 0.5.0)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
rexml (3.2.5)
|
43
|
+
rubocop (0.81.0)
|
44
|
+
jaro_winkler (~> 1.5.1)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 2.7.0.1)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
rexml
|
47
49
|
ruby-progressbar (~> 1.7)
|
48
|
-
unicode-display_width (
|
49
|
-
|
50
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
51
|
+
rubocop-performance (1.5.2)
|
52
|
+
rubocop (>= 0.71.0)
|
53
|
+
ruby-progressbar (1.11.0)
|
50
54
|
simplecov (0.9.1)
|
51
55
|
docile (~> 1.1.0)
|
52
56
|
multi_json (~> 1.0)
|
53
57
|
simplecov-html (~> 0.8.0)
|
54
58
|
simplecov-html (0.8.0)
|
55
|
-
unicode-display_width (1.0
|
59
|
+
unicode-display_width (1.8.0)
|
56
60
|
|
57
61
|
PLATFORMS
|
58
62
|
ruby
|
@@ -60,15 +64,16 @@ PLATFORMS
|
|
60
64
|
DEPENDENCIES
|
61
65
|
bacon
|
62
66
|
claide!
|
63
|
-
codeclimate-test-reporter
|
64
67
|
colored
|
65
|
-
json
|
68
|
+
json (< 3)
|
66
69
|
kicker
|
67
70
|
mocha-on-bacon
|
71
|
+
parallel (<= 1.19.2)
|
68
72
|
prettybacon
|
69
73
|
rake
|
70
|
-
rubocop
|
74
|
+
rubocop (<= 0.81.0)
|
75
|
+
rubocop-performance (<= 1.5.2)
|
71
76
|
simplecov
|
72
77
|
|
73
78
|
BUNDLED WITH
|
74
|
-
|
79
|
+
2.3.4
|
@@ -1,8 +1,7 @@
|
|
1
1
|
# Hi, I’m Claide, your command-line tool aide.
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/CocoaPods/CLAide)
|
3
|
+
[](https://github.com/CocoaPods/claide/actions)
|
4
|
+
[](https://rubygems.org/gems/claide)
|
6
5
|
|
7
6
|
I was born out of a need for a _simple_ option and command parser, while still
|
8
7
|
providing an API that allows you to quickly create a full featured command-line
|
@@ -28,24 +27,24 @@ by the user.
|
|
28
27
|
Working with parameters is done through the `CLAide::ARGV` class. It takes an
|
29
28
|
array of parameters and parses them as either flags, options, or arguments.
|
30
29
|
|
31
|
-
| Parameter
|
32
|
-
| :---:
|
33
|
-
| `--milk`, `--no-milk`
|
34
|
-
| `--
|
35
|
-
| `tea`
|
30
|
+
| Parameter | Description |
|
31
|
+
| :---: | :---: |
|
32
|
+
| `--milk`, `--no-milk` | A boolean ‘flag’, which may be negated. |
|
33
|
+
| `--sweetener=honey` | An ‘option’ consists of a key, a ‘=’, and a value. |
|
34
|
+
| `tea` | An ‘argument’ is just a value. |
|
36
35
|
|
37
36
|
|
38
37
|
Accessing flags, options, and arguments, with the following methods, will also
|
39
38
|
remove the parameter from the remaining unprocessed parameters.
|
40
39
|
|
41
40
|
```ruby
|
42
|
-
argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
43
|
-
argv.shift_argument
|
44
|
-
argv.shift_argument
|
45
|
-
argv.flag?('milk')
|
46
|
-
argv.flag?('milk')
|
47
|
-
argv.option('
|
48
|
-
argv.option('
|
41
|
+
argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
42
|
+
argv.shift_argument # => 'tea'
|
43
|
+
argv.shift_argument # => nil
|
44
|
+
argv.flag?('milk') # => false
|
45
|
+
argv.flag?('milk') # => nil
|
46
|
+
argv.option('sweetener') # => 'honey'
|
47
|
+
argv.option('sweetener') # => nil
|
49
48
|
```
|
50
49
|
|
51
50
|
|
@@ -55,7 +54,7 @@ specify a default value to be used as the optional second method parameter:
|
|
55
54
|
```ruby
|
56
55
|
argv = CLAide::ARGV.new(['tea'])
|
57
56
|
argv.flag?('milk', true) # => true
|
58
|
-
argv.option('
|
57
|
+
argv.option('sweetener', 'sugar') # => 'sugar'
|
59
58
|
```
|
60
59
|
|
61
60
|
|
@@ -111,8 +110,6 @@ should not be a need to validate the parameters.
|
|
111
110
|
See the [example][example] for a illustration of how to define commands.
|
112
111
|
|
113
112
|
|
114
|
-
[travis]: https://secure.travis-ci.org/CocoaPods/CLAide
|
115
|
-
[travis-status]: https://secure.travis-ci.org/CocoaPods/CLAide.png
|
116
113
|
[docs]: http://www.rubydoc.info/github/CocoaPods/CLAide/index
|
117
114
|
[example]: https://github.com/CocoaPods/CLAide/blob/master/examples/make.rb
|
118
115
|
[report-error]: https://github.com/CocoaPods/CocoaPods/blob/054fe5c861d932219ec40a91c0439a7cfc3a420c/lib/cocoapods/command.rb#L36
|
data/Rakefile
CHANGED
@@ -28,7 +28,7 @@ begin
|
|
28
28
|
files = FileList['spec/**/*_spec.rb'].shuffle.join(' ')
|
29
29
|
sh "bundle exec bacon #{files}"
|
30
30
|
|
31
|
-
Rake::Task['rubocop'].invoke
|
31
|
+
Rake::Task['rubocop'].invoke
|
32
32
|
end
|
33
33
|
|
34
34
|
#-- Rubocop ----------------------------------------------------------------#
|
data/claide.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
-
require 'claide'
|
3
|
+
require File.expand_path('../lib/claide/gem_version', __FILE__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "claide"
|
@@ -18,4 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rubygems_version = "1.6.2"
|
19
19
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
20
20
|
s.specification_version = 3 if s.respond_to? :specification_version
|
21
|
+
|
22
|
+
s.required_ruby_version = ">= 2.3.0"
|
21
23
|
end
|
data/lib/claide/argv.rb
CHANGED
@@ -38,9 +38,9 @@ module CLAide
|
|
38
38
|
#
|
39
39
|
# @example
|
40
40
|
#
|
41
|
-
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
41
|
+
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
42
42
|
# argv.shift_argument # => 'tea'
|
43
|
-
# argv.remainder # => ['--no-milk', '--
|
43
|
+
# argv.remainder # => ['--no-milk', '--sweetener=honey']
|
44
44
|
#
|
45
45
|
def remainder
|
46
46
|
@entries.map do |type, (key, value)|
|
@@ -60,9 +60,9 @@ module CLAide
|
|
60
60
|
#
|
61
61
|
# @example
|
62
62
|
#
|
63
|
-
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
63
|
+
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
64
64
|
# argv.shift_argument # => 'tea'
|
65
|
-
# argv.remainder! # => ['--no-milk', '--
|
65
|
+
# argv.remainder! # => ['--no-milk', '--sweetener=honey']
|
66
66
|
# argv.remainder # => []
|
67
67
|
#
|
68
68
|
def remainder!
|
@@ -74,8 +74,8 @@ module CLAide
|
|
74
74
|
#
|
75
75
|
# @example
|
76
76
|
#
|
77
|
-
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
78
|
-
# argv.options # => { 'milk' => false, '
|
77
|
+
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
78
|
+
# argv.options # => { 'milk' => false, 'sweetener' => 'honey' }
|
79
79
|
#
|
80
80
|
def options
|
81
81
|
options = {}
|
@@ -149,11 +149,11 @@ module CLAide
|
|
149
149
|
#
|
150
150
|
# @example
|
151
151
|
#
|
152
|
-
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
152
|
+
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
153
153
|
# argv.flag?('milk') # => false
|
154
154
|
# argv.flag?('milk') # => nil
|
155
155
|
# argv.flag?('milk', true) # => true
|
156
|
-
# argv.remainder # => ['tea', '--
|
156
|
+
# argv.remainder # => ['tea', '--sweetener=honey']
|
157
157
|
#
|
158
158
|
def flag?(name, default = nil)
|
159
159
|
delete_entry(:flag, name, default, true)
|
@@ -174,10 +174,10 @@ module CLAide
|
|
174
174
|
#
|
175
175
|
# @example
|
176
176
|
#
|
177
|
-
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--
|
178
|
-
# argv.option('
|
179
|
-
# argv.option('
|
180
|
-
# argv.option('
|
177
|
+
# argv = CLAide::ARGV.new(['tea', '--no-milk', '--sweetener=honey'])
|
178
|
+
# argv.option('sweetener') # => 'honey'
|
179
|
+
# argv.option('sweetener') # => nil
|
180
|
+
# argv.option('sweetener', 'sugar') # => 'sugar'
|
181
181
|
# argv.remainder # => ['tea', '--no-milk']
|
182
182
|
#
|
183
183
|
def option(name, default = nil)
|
@@ -251,10 +251,10 @@ module CLAide
|
|
251
251
|
#
|
252
252
|
# @example
|
253
253
|
#
|
254
|
-
# list = parse(['tea', '--no-milk', '--
|
254
|
+
# list = parse(['tea', '--no-milk', '--sweetener=honey'])
|
255
255
|
# list # => [[:arg, "tea"],
|
256
256
|
# [:flag, ["milk", false]],
|
257
|
-
# [:option, ["
|
257
|
+
# [:option, ["sweetener", "honey"]]]
|
258
258
|
#
|
259
259
|
def self.parse(argv)
|
260
260
|
entries = []
|
@@ -28,7 +28,7 @@ module CLAide
|
|
28
28
|
def self.load_plugins(plugin_prefix)
|
29
29
|
loaded_plugins[plugin_prefix] ||=
|
30
30
|
plugin_gems_for_prefix(plugin_prefix).map do |spec, paths|
|
31
|
-
spec if
|
31
|
+
spec if safe_require(paths)
|
32
32
|
end.compact
|
33
33
|
end
|
34
34
|
|
@@ -56,7 +56,7 @@ module CLAide
|
|
56
56
|
def self.plugins_involved_in_exception(exception)
|
57
57
|
specifications.select do |gemspec|
|
58
58
|
exception.backtrace.any? do |line|
|
59
|
-
gemspec.
|
59
|
+
full_require_paths_for(gemspec).any? do |plugin_path|
|
60
60
|
line.include?(plugin_path)
|
61
61
|
end
|
62
62
|
end
|
@@ -77,33 +77,48 @@ module CLAide
|
|
77
77
|
end.compact
|
78
78
|
end
|
79
79
|
|
80
|
-
#
|
80
|
+
# Requires the given paths.
|
81
81
|
# If any exception occurs it is caught and an
|
82
82
|
# informative message is printed.
|
83
83
|
#
|
84
|
-
# @param [Gem::Specification] spec
|
85
|
-
# The spec to be activated.
|
86
|
-
#
|
87
84
|
# @param [String] paths
|
88
85
|
# The paths to require.
|
89
86
|
#
|
90
|
-
# @return [Bool] Whether
|
87
|
+
# @return [Bool] Whether requiring succeeded.
|
91
88
|
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
def self.safe_require(paths)
|
90
|
+
paths.each do |path|
|
91
|
+
begin
|
92
|
+
require(path)
|
93
|
+
rescue Exception => exception # rubocop:disable RescueException
|
94
|
+
message = "\n---------------------------------------------"
|
95
|
+
message << "\nError loading plugin file `#{path}`.\n"
|
96
|
+
message << "\n#{exception.class} - #{exception.message}"
|
97
|
+
message << "\n#{exception.backtrace.join("\n")}"
|
98
|
+
message << "\n---------------------------------------------\n"
|
99
|
+
warn message.ansi.yellow
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
96
104
|
true
|
97
|
-
rescue Exception => exception
|
98
|
-
message = "\n---------------------------------------------"
|
99
|
-
message << "\nError loading the plugin `#{spec.full_name}`.\n"
|
100
|
-
message << "\n#{exception.class} - #{exception.message}"
|
101
|
-
message << "\n#{exception.backtrace.join("\n")}"
|
102
|
-
message << "\n---------------------------------------------\n"
|
103
|
-
warn message.ansi.yellow
|
104
|
-
false
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
|
+
def self.full_require_paths_for(gemspec)
|
108
|
+
if gemspec.respond_to?(:full_require_paths)
|
109
|
+
return gemspec.full_require_paths
|
110
|
+
end
|
111
|
+
|
112
|
+
# RubyGems < 2.2
|
113
|
+
gemspec.require_paths.map do |require_path|
|
114
|
+
if require_path.include?(gemspec.full_gem_path)
|
115
|
+
require_path
|
116
|
+
else
|
117
|
+
File.join(gemspec.full_gem_path, require_path)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
private_class_method :full_require_paths_for
|
107
122
|
end
|
108
123
|
end
|
109
124
|
end
|
data/lib/claide/command.rb
CHANGED
@@ -80,7 +80,7 @@ module CLAide
|
|
80
80
|
#
|
81
81
|
attr_accessor :description
|
82
82
|
|
83
|
-
# @return [Array<String>] The prefixes used
|
83
|
+
# @return [Array<String>] The prefixes used to search for CLAide plugins.
|
84
84
|
# Plugins are loaded via their `<plugin_prefix>_plugin.rb` file.
|
85
85
|
# Defaults to search for `claide` plugins.
|
86
86
|
#
|
@@ -233,7 +233,7 @@ module CLAide
|
|
233
233
|
#
|
234
234
|
# The subclass has to combine the result of calling `super` and its own
|
235
235
|
# list of options. The recommended way of doing this is by concatenating
|
236
|
-
#
|
236
|
+
# to this classes’ own options.
|
237
237
|
#
|
238
238
|
# @return [Array<Array>]
|
239
239
|
#
|
@@ -497,6 +497,15 @@ module CLAide
|
|
497
497
|
attr_accessor :ansi_output
|
498
498
|
alias_method :ansi_output?, :ansi_output
|
499
499
|
|
500
|
+
# Set to `true` if initialized with a `--help` flag
|
501
|
+
#
|
502
|
+
# @return [Boolean]
|
503
|
+
#
|
504
|
+
# Whether the command was initialized with argv containing --help
|
505
|
+
#
|
506
|
+
attr_accessor :help_arg
|
507
|
+
alias_method :help?, :help_arg
|
508
|
+
|
500
509
|
# Subclasses should override this method to remove the arguments/options
|
501
510
|
# they support from `argv` _before_ calling `super`.
|
502
511
|
#
|
@@ -514,6 +523,7 @@ module CLAide
|
|
514
523
|
@verbose = argv.flag?('verbose')
|
515
524
|
@ansi_output = argv.flag?('ansi', Command.ansi_output?)
|
516
525
|
@argv = argv
|
526
|
+
@help_arg = argv.flag?('help')
|
517
527
|
end
|
518
528
|
|
519
529
|
# Convenience method.
|
@@ -553,7 +563,7 @@ module CLAide
|
|
553
563
|
# @return [void]
|
554
564
|
#
|
555
565
|
def validate!
|
556
|
-
banner! if
|
566
|
+
banner! if help?
|
557
567
|
unless @argv.empty?
|
558
568
|
argument = @argv.remainder.first
|
559
569
|
help! ArgumentSuggester.new(argument, self.class).suggestion
|
@@ -564,7 +574,7 @@ module CLAide
|
|
564
574
|
# This method should be overridden by the command class to perform its
|
565
575
|
# work.
|
566
576
|
#
|
567
|
-
# @return [void
|
577
|
+
# @return [void]
|
568
578
|
#
|
569
579
|
def run
|
570
580
|
raise 'A subclass should override the `CLAide::Command#run` method to ' \
|
data/lib/claide.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
8
8
|
- Fabio Pelosin
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
14
|
+
description:
|
15
15
|
email:
|
16
16
|
- eloy.de.enige@gmail.com
|
17
17
|
- fabiopelosin@gmail.com
|
@@ -19,18 +19,18 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- ".github/workflows/ci.yml"
|
22
23
|
- ".gitignore"
|
23
24
|
- ".kick"
|
24
25
|
- ".rubocop.yml"
|
25
26
|
- ".rubocop_cocoapods.yml"
|
26
27
|
- ".rubocop_todo.yml"
|
27
|
-
- ".travis.yml"
|
28
28
|
- ".yardopts"
|
29
29
|
- CHANGELOG.md
|
30
30
|
- Gemfile
|
31
31
|
- Gemfile.lock
|
32
32
|
- LICENSE
|
33
|
-
- README.
|
33
|
+
- README.md
|
34
34
|
- Rakefile
|
35
35
|
- claide.gemspec
|
36
36
|
- lib/claide.rb
|
@@ -44,13 +44,14 @@ files:
|
|
44
44
|
- lib/claide/command/argument_suggester.rb
|
45
45
|
- lib/claide/command/banner.rb
|
46
46
|
- lib/claide/command/plugin_manager.rb
|
47
|
+
- lib/claide/gem_version.rb
|
47
48
|
- lib/claide/help.rb
|
48
49
|
- lib/claide/informative_error.rb
|
49
50
|
homepage: https://github.com/CocoaPods/CLAide
|
50
51
|
licenses:
|
51
52
|
- MIT
|
52
53
|
metadata: {}
|
53
|
-
post_install_message:
|
54
|
+
post_install_message:
|
54
55
|
rdoc_options: []
|
55
56
|
require_paths:
|
56
57
|
- lib
|
@@ -58,16 +59,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
59
|
requirements:
|
59
60
|
- - ">="
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
+
version: 2.3.0
|
62
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
64
|
requirements:
|
64
65
|
- - ">="
|
65
66
|
- !ruby/object:Gem::Version
|
66
67
|
version: '0'
|
67
68
|
requirements: []
|
68
|
-
|
69
|
-
|
70
|
-
signing_key:
|
69
|
+
rubygems_version: 3.2.3
|
70
|
+
signing_key:
|
71
71
|
specification_version: 3
|
72
72
|
summary: A small command-line interface framework.
|
73
73
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
addons:
|
3
|
-
code_climate:
|
4
|
-
repo_token: 46c8b29dd6711f35704e7c5a541486cbbf2cff8b2df8ce755bfc09917d3c1cbb
|
5
|
-
branches:
|
6
|
-
only:
|
7
|
-
- master
|
8
|
-
- /.+-stable$/
|
9
|
-
rvm:
|
10
|
-
- 1.8.7
|
11
|
-
- 1.9.3
|
12
|
-
- 2.1.1
|
13
|
-
bundler_args: --without development
|
14
|
-
before_install: gem install bundler
|
15
|
-
script: bundle exec rake spec
|