atli 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/atli.gemspec +3 -1
- data/lib/thor.rb +748 -732
- data/lib/thor/base.rb +160 -92
- data/lib/thor/base/arguments_concern.rb +298 -0
- data/lib/thor/base/class_methods.rb +31 -120
- data/lib/thor/base/shared_concern.rb +123 -0
- data/lib/thor/base/shared_options_concern.rb +235 -0
- data/lib/thor/command.rb +51 -6
- data/lib/thor/completion/bash.rb +71 -126
- data/lib/thor/completion/bash/argument_mixin.rb +83 -0
- data/lib/thor/completion/bash/command_mixin.rb +236 -0
- data/lib/thor/completion/bash/request.rb +48 -0
- data/lib/thor/completion/bash/subcmd.rb +136 -0
- data/lib/thor/completion/bash/thor_mixin.rb +250 -0
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +15 -1
- data/lib/thor/execution.rb +2 -1
- data/lib/thor/parser/argument.rb +61 -10
- data/lib/thor/parser/arguments.rb +3 -1
- data/lib/thor/parser/option.rb +49 -0
- data/lib/thor/parser/options.rb +10 -7
- data/lib/thor/version.rb +13 -2
- metadata +26 -5
- data/lib/thor/core_ext/ordered_hash.rb +0 -129
data/lib/thor/execution.rb
CHANGED
data/lib/thor/parser/argument.rb
CHANGED
@@ -1,8 +1,51 @@
|
|
1
1
|
class Thor
|
2
|
-
class Argument
|
2
|
+
class Argument
|
3
|
+
|
4
|
+
# Constants
|
5
|
+
# ========================================================================
|
6
|
+
|
3
7
|
VALID_TYPES = [:numeric, :hash, :array, :string]
|
4
8
|
|
9
|
+
|
10
|
+
# Mixins
|
11
|
+
# ========================================================================
|
12
|
+
|
13
|
+
include NRSER::Log::Mixin
|
14
|
+
|
15
|
+
|
16
|
+
# Attributes
|
17
|
+
# ========================================================================
|
18
|
+
|
5
19
|
attr_reader :name, :description, :enum, :required, :type, :default, :banner
|
20
|
+
|
21
|
+
|
22
|
+
# Optional block to provide dynamic shell completion.
|
23
|
+
#
|
24
|
+
# @return [nil]
|
25
|
+
# This argument does not provide dynamic completion.
|
26
|
+
#
|
27
|
+
# @return [Proc<() => Array<String>>]
|
28
|
+
# Arity `0` proc that will be called with no arguments to provide
|
29
|
+
# dynamic completion options.
|
30
|
+
#
|
31
|
+
# @return [Proc<(request:, klass:, command:) => Array<String>]
|
32
|
+
# Arity `-1` proc that will be passed:
|
33
|
+
#
|
34
|
+
# - {Thor::Completion::Bash::Request} `request:`
|
35
|
+
# The completion request.
|
36
|
+
#
|
37
|
+
# - {Class<Thor::Base>} `klass:`
|
38
|
+
# The {Thor} or {Thor::Group} subclass being completed.
|
39
|
+
#
|
40
|
+
# - {Thor::Command} `command:`
|
41
|
+
# The command being completed.
|
42
|
+
#
|
43
|
+
# As in the arity `0` case, must return an array of string completion
|
44
|
+
# options.
|
45
|
+
#
|
46
|
+
attr_reader :complete
|
47
|
+
|
48
|
+
|
6
49
|
alias_method :human_name, :name
|
7
50
|
|
8
51
|
def initialize(name, options = {})
|
@@ -10,16 +53,24 @@ class Thor
|
|
10
53
|
|
11
54
|
type = options[:type]
|
12
55
|
|
13
|
-
|
14
|
-
|
56
|
+
if name.nil?
|
57
|
+
raise ArgumentError,
|
58
|
+
"#{class_name} name can't be nil."
|
59
|
+
end
|
60
|
+
|
61
|
+
if type && !valid_type?(type)
|
62
|
+
raise ArgumentError,
|
63
|
+
"Type :#{type} is not valid for #{class_name.downcase}s."
|
64
|
+
end
|
15
65
|
|
16
|
-
@name
|
17
|
-
@description
|
18
|
-
@required
|
19
|
-
@type
|
20
|
-
@default
|
21
|
-
@banner
|
22
|
-
@enum
|
66
|
+
@name = name.to_s
|
67
|
+
@description = options[:desc]
|
68
|
+
@required = options.key?(:required) ? options[:required] : true
|
69
|
+
@type = (type || :string).to_sym
|
70
|
+
@default = options[:default]
|
71
|
+
@banner = options[:banner] || default_banner
|
72
|
+
@enum = options[:enum]
|
73
|
+
@complete = options[:complete]
|
23
74
|
|
24
75
|
validate! # Trigger specific validations
|
25
76
|
end
|
data/lib/thor/parser/option.rb
CHANGED
@@ -3,6 +3,8 @@ require 'active_support/core_ext/string/inflections'
|
|
3
3
|
|
4
4
|
class Thor
|
5
5
|
class Option < Argument #:nodoc:
|
6
|
+
include NRSER::Log::Mixin
|
7
|
+
|
6
8
|
attr_reader :aliases, :group, :lazy_default, :hide
|
7
9
|
|
8
10
|
VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
|
@@ -78,6 +80,53 @@ class Thor
|
|
78
80
|
@switch_name ||= dasherized? ? name : dasherize(name)
|
79
81
|
end
|
80
82
|
|
83
|
+
|
84
|
+
def self.alias_to_switch_name alias_name
|
85
|
+
alias_name.sub( /\A\-{1,2}/, '' ).dasherize
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def all_switch_names
|
90
|
+
[
|
91
|
+
name.dasherize,
|
92
|
+
*aliases.map { |alias_name|
|
93
|
+
self.class.alias_to_switch_name( alias_name )
|
94
|
+
}
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def short_switch_names
|
100
|
+
all_switch_names.select { |name| name.length == 1 }
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def short_switch_tokens
|
105
|
+
short_switch_names.map { |name| "-#{ name }" }
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def long_switch_names
|
110
|
+
all_switch_names.select { |name| name.length > 1 }
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def long_switch_tokens
|
115
|
+
if boolean?
|
116
|
+
long_switch_names.flat_map { |name|
|
117
|
+
[ "--#{ name }", "--no-#{ name }" ]
|
118
|
+
}
|
119
|
+
else
|
120
|
+
long_switch_names.map { |name| "--#{ name }" }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def all_switch_tokens
|
126
|
+
[*long_switch_tokens, *short_switch_tokens]
|
127
|
+
end
|
128
|
+
|
129
|
+
|
81
130
|
def human_name
|
82
131
|
@human_name ||= dasherized? ? undasherize(name) : name
|
83
132
|
end
|
data/lib/thor/parser/options.rb
CHANGED
@@ -65,19 +65,22 @@ class Thor
|
|
65
65
|
# @param [Hash<Symbol, Thor::Option>] hash_options
|
66
66
|
#
|
67
67
|
#
|
68
|
-
def initialize
|
69
|
-
|
68
|
+
def initialize options_to_parse_by_name = {},
|
69
|
+
option_default_values = {},
|
70
70
|
stop_on_unknown = false,
|
71
71
|
disable_required_check = false
|
72
72
|
@stop_on_unknown = stop_on_unknown
|
73
73
|
@disable_required_check = disable_required_check
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
options = options_to_parse_by_name.values
|
76
|
+
super( options )
|
76
77
|
|
77
78
|
# Add defaults
|
78
|
-
|
79
|
-
@assigns[
|
80
|
-
|
79
|
+
option_default_values.each do |option_name, value|
|
80
|
+
@assigns[ option_name.to_s ] = value
|
81
|
+
|
82
|
+
@non_assigned_required.delete \
|
83
|
+
options_to_parse_by_name[ option_name ]
|
81
84
|
end
|
82
85
|
|
83
86
|
@shorts = {}
|
data/lib/thor/version.rb
CHANGED
@@ -14,7 +14,7 @@ class Thor
|
|
14
14
|
#
|
15
15
|
# @return [String]
|
16
16
|
#
|
17
|
-
VERSION = '0.1.
|
17
|
+
VERSION = '0.1.10'
|
18
18
|
|
19
19
|
|
20
20
|
# The version of Thor that Atli is up to date with.
|
@@ -27,5 +27,16 @@ class Thor
|
|
27
27
|
#
|
28
28
|
# @return [String]
|
29
29
|
#
|
30
|
-
THOR_VERSION = '0.1.
|
30
|
+
THOR_VERSION = '0.1.10'
|
31
|
+
|
32
|
+
|
33
|
+
# Are we running from the source code (vesus from a Gem install)?
|
34
|
+
#
|
35
|
+
# Looks for the `//dev` directory, which is not included in the package.
|
36
|
+
#
|
37
|
+
# @return [Boolean]
|
38
|
+
#
|
39
|
+
def self.running_from_source?
|
40
|
+
( ROOT + 'dev' ).directory?
|
41
|
+
end
|
31
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Souza (Atli)
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-07-
|
13
|
+
date: 2018-07-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.3.
|
35
|
+
version: 0.3.9
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.3.
|
42
|
+
version: 0.3.9
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: yard
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 0.9.12
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: yard-activesupport-concern
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.0.1
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.0.1
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: redcarpet
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,13 +105,20 @@ files:
|
|
91
105
|
- lib/thor/actions/file_manipulation.rb
|
92
106
|
- lib/thor/actions/inject_into_file.rb
|
93
107
|
- lib/thor/base.rb
|
108
|
+
- lib/thor/base/arguments_concern.rb
|
94
109
|
- lib/thor/base/class_methods.rb
|
95
110
|
- lib/thor/base/common_class_options.rb
|
111
|
+
- lib/thor/base/shared_concern.rb
|
112
|
+
- lib/thor/base/shared_options_concern.rb
|
96
113
|
- lib/thor/command.rb
|
97
114
|
- lib/thor/completion/bash.rb
|
115
|
+
- lib/thor/completion/bash/argument_mixin.rb
|
116
|
+
- lib/thor/completion/bash/command_mixin.rb
|
117
|
+
- lib/thor/completion/bash/request.rb
|
118
|
+
- lib/thor/completion/bash/subcmd.rb
|
119
|
+
- lib/thor/completion/bash/thor_mixin.rb
|
98
120
|
- lib/thor/core_ext/hash_with_indifferent_access.rb
|
99
121
|
- lib/thor/core_ext/io_binary_read.rb
|
100
|
-
- lib/thor/core_ext/ordered_hash.rb
|
101
122
|
- lib/thor/error.rb
|
102
123
|
- lib/thor/example.rb
|
103
124
|
- lib/thor/execution.rb
|
@@ -1,129 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
module CoreExt
|
3
|
-
class OrderedHash < ::Hash
|
4
|
-
if RUBY_VERSION < "1.9"
|
5
|
-
def initialize(*args, &block)
|
6
|
-
super
|
7
|
-
@keys = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize_copy(other)
|
11
|
-
super
|
12
|
-
# make a deep copy of keys
|
13
|
-
@keys = other.keys
|
14
|
-
end
|
15
|
-
|
16
|
-
def []=(key, value)
|
17
|
-
@keys << key unless key?(key)
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete(key)
|
22
|
-
if key? key
|
23
|
-
index = @keys.index(key)
|
24
|
-
@keys.delete_at index
|
25
|
-
end
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def delete_if
|
30
|
-
super
|
31
|
-
sync_keys!
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
alias_method :reject!, :delete_if
|
36
|
-
|
37
|
-
def reject(&block)
|
38
|
-
dup.reject!(&block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def keys
|
42
|
-
@keys.dup
|
43
|
-
end
|
44
|
-
|
45
|
-
def values
|
46
|
-
@keys.map { |key| self[key] }
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_hash
|
50
|
-
self
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_a
|
54
|
-
@keys.map { |key| [key, self[key]] }
|
55
|
-
end
|
56
|
-
|
57
|
-
def each_key
|
58
|
-
return to_enum(:each_key) unless block_given?
|
59
|
-
@keys.each { |key| yield(key) }
|
60
|
-
self
|
61
|
-
end
|
62
|
-
|
63
|
-
def each_value
|
64
|
-
return to_enum(:each_value) unless block_given?
|
65
|
-
@keys.each { |key| yield(self[key]) }
|
66
|
-
self
|
67
|
-
end
|
68
|
-
|
69
|
-
def each
|
70
|
-
return to_enum(:each) unless block_given?
|
71
|
-
@keys.each { |key| yield([key, self[key]]) }
|
72
|
-
self
|
73
|
-
end
|
74
|
-
|
75
|
-
def each_pair
|
76
|
-
return to_enum(:each_pair) unless block_given?
|
77
|
-
@keys.each { |key| yield(key, self[key]) }
|
78
|
-
self
|
79
|
-
end
|
80
|
-
|
81
|
-
alias_method :select, :find_all
|
82
|
-
|
83
|
-
def clear
|
84
|
-
super
|
85
|
-
@keys.clear
|
86
|
-
self
|
87
|
-
end
|
88
|
-
|
89
|
-
def shift
|
90
|
-
k = @keys.first
|
91
|
-
v = delete(k)
|
92
|
-
[k, v]
|
93
|
-
end
|
94
|
-
|
95
|
-
def merge!(other_hash)
|
96
|
-
if block_given?
|
97
|
-
other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
|
98
|
-
else
|
99
|
-
other_hash.each { |k, v| self[k] = v }
|
100
|
-
end
|
101
|
-
self
|
102
|
-
end
|
103
|
-
|
104
|
-
alias_method :update, :merge!
|
105
|
-
|
106
|
-
def merge(other_hash, &block)
|
107
|
-
dup.merge!(other_hash, &block)
|
108
|
-
end
|
109
|
-
|
110
|
-
# When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
|
111
|
-
def replace(other)
|
112
|
-
super
|
113
|
-
@keys = other.keys
|
114
|
-
self
|
115
|
-
end
|
116
|
-
|
117
|
-
def inspect
|
118
|
-
"#<#{self.class} #{super}>"
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
|
123
|
-
def sync_keys!
|
124
|
-
@keys.delete_if { |k| !key?(k) }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|