thor 0.20.0 → 1.2.1
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/README.md +7 -9
- data/lib/thor/actions/create_file.rb +1 -1
- data/lib/thor/actions/create_link.rb +3 -2
- data/lib/thor/actions/directory.rb +7 -17
- data/lib/thor/actions/file_manipulation.rb +25 -14
- data/lib/thor/actions/inject_into_file.rb +20 -10
- data/lib/thor/actions.rb +34 -15
- data/lib/thor/base.rb +63 -43
- data/lib/thor/command.rb +21 -14
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
- data/lib/thor/error.rb +83 -0
- data/lib/thor/group.rb +3 -3
- data/lib/thor/invocation.rb +1 -0
- data/lib/thor/line_editor/basic.rb +1 -1
- data/lib/thor/line_editor/readline.rb +6 -6
- data/lib/thor/line_editor.rb +2 -2
- data/lib/thor/nested_context.rb +29 -0
- data/lib/thor/parser/arguments.rb +7 -3
- data/lib/thor/parser/option.rb +20 -7
- data/lib/thor/parser/options.rb +40 -6
- data/lib/thor/parser.rb +4 -4
- data/lib/thor/rake_compat.rb +1 -0
- data/lib/thor/runner.rb +5 -4
- data/lib/thor/shell/basic.rb +87 -12
- data/lib/thor/shell/color.rb +10 -2
- data/lib/thor/shell/html.rb +3 -3
- data/lib/thor/shell.rb +5 -5
- data/lib/thor/util.rb +18 -2
- data/lib/thor/version.rb +1 -1
- data/lib/thor.rb +16 -9
- data/thor.gemspec +10 -2
- metadata +20 -11
- data/CHANGELOG.md +0 -193
- data/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/lib/thor/core_ext/ordered_hash.rb +0 -129
data/CHANGELOG.md
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
## 0.20.0
|
2
|
-
* Add `check_default_type!` to check if the default value of an option matches the defined type.
|
3
|
-
It removes the warning on usage and gives the command authors the possibility to check for programming errors.
|
4
|
-
|
5
|
-
* Add `disable_required_check!` to disable check for required options in some commands.
|
6
|
-
It is a substitute of `disable_class_options` that was not working as intended.
|
7
|
-
|
8
|
-
* Add `inject_into_module`.
|
9
|
-
|
10
|
-
## 0.19.4, release 2016-11-28
|
11
|
-
* Rename `Thor::Base#thor_reserved_word?` to `#is_thor_reserved_word?`
|
12
|
-
|
13
|
-
## 0.19.3, release 2016-11-27
|
14
|
-
* Output a warning instead of raising an exception when a default option value doesn't match its specified type
|
15
|
-
|
16
|
-
## 0.19.2, release 2016-11-26
|
17
|
-
* Fix bug with handling of colors passed to `ask` (and methods like `yes?` and `no?` which it underpins)
|
18
|
-
* Allow numeric arguments to be negative
|
19
|
-
* Ensure that default option values are of the specified type (e.g. you can't specify `"foo"` as the default for a numeric option), but make symbols and strings interchangeable
|
20
|
-
* Add `Thor::Shell::Basic#indent` method for intending output
|
21
|
-
* Fix `remove_command` for an inherited command (see #451)
|
22
|
-
* Allow hash arguments to only have each key provided once (see #455)
|
23
|
-
* Allow commands to disable class options, for instance for "help" commands (see #363)
|
24
|
-
* Do not generate a negative option (`--no-no-foo`) for already negative boolean options (`--no-foo`)
|
25
|
-
* Improve compatibility of `Thor::CoreExt::HashWithIndifferentAccess` with Ruby standard library `Hash`
|
26
|
-
* Allow specifying a custom binding for template evaluation (e.g. `#key?` and `#fetch`)
|
27
|
-
* Fix support for subcommand-specific "help"s
|
28
|
-
* Use a string buffer when handling ERB for Ruby 2.3 compatibility
|
29
|
-
* Update dependencies
|
30
|
-
|
31
|
-
## 0.19.1, release 2014-03-24
|
32
|
-
* Fix `say` non-String break regression
|
33
|
-
|
34
|
-
## 0.19.0, release 2014-03-22
|
35
|
-
* Add support for a default to #ask
|
36
|
-
* Avoid @namespace not initialized warning
|
37
|
-
* Avoid private attribute? warning
|
38
|
-
* Fix initializing with unknown options
|
39
|
-
* Loosen required_rubygems_version for compatibility with Ubuntu 10.04
|
40
|
-
* Shell#ask: support a noecho option for stdin
|
41
|
-
* Shell#ask: change API to be :echo => false
|
42
|
-
* Display a message without a stack trace for ambiguous commands
|
43
|
-
* Make say and say_status thread safe
|
44
|
-
* Dependency for console io version check
|
45
|
-
* Alias --help to help on subcommands
|
46
|
-
* Use mime-types 1.x for Ruby 1.8.7 compatibility for Ruby 1.8 only
|
47
|
-
* Accept .tt files as templates
|
48
|
-
* Check if numeric value is in enum
|
49
|
-
* Use Readline for user input
|
50
|
-
* Fix dispatching of subcommands (concerning :help and *args)
|
51
|
-
* Fix warnings when running specs with `$VERBOSE = true`
|
52
|
-
* Make subcommand help more consistent
|
53
|
-
* Make the current command chain accessible in command
|
54
|
-
|
55
|
-
## 0.18.1, release 2013-03-30
|
56
|
-
* Revert regressions found in 0.18.0
|
57
|
-
|
58
|
-
## 0.18.0, release 2013-03-26
|
59
|
-
* Remove rake2thor
|
60
|
-
* Only display colors if output medium supports colors
|
61
|
-
* Pass parent_options to subcommands
|
62
|
-
* Fix non-dash-prefixed aliases
|
63
|
-
* Make error messages more helpful
|
64
|
-
* Rename "task" to "command"
|
65
|
-
* Add the method to allow for custom package name
|
66
|
-
|
67
|
-
## 0.17.0, release 2013-01-24
|
68
|
-
* Add better support for tasks that accept arbitrary additional arguments (e.g. things like `bundle exec`)
|
69
|
-
* Add #stop_on_unknown_option!
|
70
|
-
* Only strip from stdin.gets if it wasn't ended with EOF
|
71
|
-
* Allow "send" as a task name
|
72
|
-
* Allow passing options as arguments after "--"
|
73
|
-
* Autoload Thor::Group
|
74
|
-
|
75
|
-
## 0.16.0, release 2012-08-14
|
76
|
-
* Add enum to string arguments
|
77
|
-
|
78
|
-
## 0.15.4, release 2012-06-29
|
79
|
-
* Fix regression when destination root contains reserved regexp characters
|
80
|
-
|
81
|
-
## 0.15.3, release 2012-06-18
|
82
|
-
* Support strict_args_position! for backwards compatibility
|
83
|
-
* Escape Dir glob characters in paths
|
84
|
-
|
85
|
-
## 0.15.2, released 2012-05-07
|
86
|
-
* Added print_in_columns
|
87
|
-
* Exposed terminal_width as a public API
|
88
|
-
|
89
|
-
## 0.15.1, release 2012-05-06
|
90
|
-
* Fix Ruby 1.8 truncation bug with unicode chars
|
91
|
-
* Fix shell delegate methods to pass their block
|
92
|
-
* Don't output trailing spaces when printing the last column in a table
|
93
|
-
|
94
|
-
## 0.15, released 2012-04-29
|
95
|
-
* Alias method_options to options
|
96
|
-
* Refactor say to allow multiple colors
|
97
|
-
* Exposed error as a public API
|
98
|
-
* Exposed file_collision as a public API
|
99
|
-
* Exposed print_wrapped as a public API
|
100
|
-
* Exposed set_color as a public API
|
101
|
-
* Fix number-formatting bugs in print_table
|
102
|
-
* Fix "indent" typo in print_table
|
103
|
-
* Fix Errno::EPIPE when piping tasks to `head`
|
104
|
-
* More friendly error messages
|
105
|
-
|
106
|
-
## 0.14, released 2010-07-25
|
107
|
-
* Added CreateLink class and #link_file method
|
108
|
-
* Made Thor::Actions#run use system as default method for system calls
|
109
|
-
* Allow use of private methods from superclass as tasks
|
110
|
-
* Added mute(&block) method which allows to run block without any output
|
111
|
-
* Removed config[:pretend]
|
112
|
-
* Enabled underscores for command line switches
|
113
|
-
* Added Thor::Base.basename which is used by both Thor.banner and Thor::Group.banner
|
114
|
-
* Deprecated invoke() without arguments
|
115
|
-
* Added :only and :except to check_unknown_options
|
116
|
-
|
117
|
-
## 0.13, released 2010-02-03
|
118
|
-
* Added :lazy_default which is only triggered if a switch is given
|
119
|
-
* Added Thor::Shell::HTML
|
120
|
-
* Added subcommands
|
121
|
-
* Decoupled Thor::Group and Thor, so it's easier to vendor
|
122
|
-
* Added check_unknown_options! in case you want error messages to be raised in valid switches
|
123
|
-
* run(command) should return the results of command
|
124
|
-
|
125
|
-
## 0.12, released 2010-01-02
|
126
|
-
* Methods generated by attr_* are automatically not marked as tasks
|
127
|
-
* inject_into_file does not add the same content twice, unless :force is set
|
128
|
-
* Removed rr in favor to rspec mock framework
|
129
|
-
* Improved output for thor -T
|
130
|
-
* [#7] Do not force white color on status
|
131
|
-
* [#8] Yield a block with the filename on directory
|
132
|
-
|
133
|
-
## 0.11, released 2009-07-01
|
134
|
-
* Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
|
135
|
-
Thor classes.
|
136
|
-
* BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore
|
137
|
-
since it may cause wrong behavior in the invocation system.
|
138
|
-
* thor help now show information about any class/task. All those calls are
|
139
|
-
possible:
|
140
|
-
|
141
|
-
thor help describe
|
142
|
-
thor help describe:amazing
|
143
|
-
Or even with default namespaces:
|
144
|
-
|
145
|
-
thor help :spec
|
146
|
-
* Thor::Runner now invokes the default task if none is supplied:
|
147
|
-
|
148
|
-
thor describe # invokes the default task, usually help
|
149
|
-
* Thor::Runner now works with mappings:
|
150
|
-
|
151
|
-
thor describe -h
|
152
|
-
* Added some documentation and code refactoring.
|
153
|
-
|
154
|
-
## 0.9.8, released 2008-10-20
|
155
|
-
* Fixed some tiny issues that were introduced lately.
|
156
|
-
|
157
|
-
## 0.9.7, released 2008-10-13
|
158
|
-
* Setting global method options on the initialize method works as expected:
|
159
|
-
All other tasks will accept these global options in addition to their own.
|
160
|
-
* Added 'group' notion to Thor task sets (class Thor); by default all tasks
|
161
|
-
are in the 'standard' group. Running 'thor -T' will only show the standard
|
162
|
-
tasks - adding --all will show all tasks. You can also filter on a specific
|
163
|
-
group using the --group option: thor -T --group advanced
|
164
|
-
|
165
|
-
## 0.9.6, released 2008-09-13
|
166
|
-
* Generic improvements
|
167
|
-
|
168
|
-
## 0.9.5, released 2008-08-27
|
169
|
-
* Improve Windows compatibility
|
170
|
-
* Update (incorrect) README and task.thor sample file
|
171
|
-
* Options hash is now frozen (once returned)
|
172
|
-
* Allow magic predicates on options object. For instance: `options.force?`
|
173
|
-
* Add support for :numeric type
|
174
|
-
* BACKWARDS INCOMPATIBLE: Refactor Thor::Options. You cannot access shorthand forms in options hash anymore (for instance, options[:f])
|
175
|
-
* Allow specifying optional args with default values: method_options(:user => "mislav")
|
176
|
-
* Don't write options for nil or false values. This allows, for example, turning color off when running specs.
|
177
|
-
* Exit with the status of the spec command to help CI stuff out some.
|
178
|
-
|
179
|
-
## 0.9.4, released 2008-08-13
|
180
|
-
* Try to add Windows compatibility.
|
181
|
-
* BACKWARDS INCOMPATIBLE: options hash is now accessed as a property in your class and is not passed as last argument anymore
|
182
|
-
* Allow options at the beginning of the argument list as well as the end.
|
183
|
-
* Make options available with symbol keys in addition to string keys.
|
184
|
-
* Allow true to be passed to Thor#method_options to denote a boolean option.
|
185
|
-
* If loading a thor file fails, don't give up, just print a warning and keep going.
|
186
|
-
* Make sure that we re-raise errors if they happened further down the pipe than we care about.
|
187
|
-
* Only delete the old file on updating when the installation of the new one is a success
|
188
|
-
* Make it Ruby 1.8.5 compatible.
|
189
|
-
* Don't raise an error if a boolean switch is defined multiple times.
|
190
|
-
* Thor::Options now doesn't parse through things that look like options but aren't.
|
191
|
-
* Add URI detection to install task, and make sure we don't append ".thor" to URIs
|
192
|
-
* Add rake2thor to the gem binfiles.
|
193
|
-
* Make sure local Thorfiles override system-wide ones.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class IO #:nodoc:
|
2
|
-
class << self
|
3
|
-
unless method_defined? :binread
|
4
|
-
def binread(file, *args)
|
5
|
-
raise ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
|
6
|
-
File.open(file, "rb") do |f|
|
7
|
-
f.read(*args)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -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
|