command_kit 0.1.0.rc1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +1 -1
- data/README.md +7 -4
- data/gemspec.yml +1 -1
- data/lib/command_kit.rb +1 -0
- data/lib/command_kit/arguments.rb +16 -1
- data/lib/command_kit/arguments/argument.rb +2 -0
- data/lib/command_kit/arguments/argument_value.rb +2 -0
- data/lib/command_kit/colors.rb +32 -0
- data/lib/command_kit/command.rb +5 -0
- data/lib/command_kit/command_name.rb +9 -0
- data/lib/command_kit/commands.rb +30 -0
- data/lib/command_kit/commands/auto_load.rb +16 -0
- data/lib/command_kit/commands/auto_require.rb +16 -0
- data/lib/command_kit/commands/command.rb +3 -0
- data/lib/command_kit/commands/help.rb +2 -0
- data/lib/command_kit/commands/parent_command.rb +7 -0
- data/lib/command_kit/commands/subcommand.rb +12 -0
- data/lib/command_kit/description.rb +12 -1
- data/lib/command_kit/env.rb +4 -0
- data/lib/command_kit/env/home.rb +9 -0
- data/lib/command_kit/env/path.rb +15 -0
- data/lib/command_kit/examples.rb +12 -1
- data/lib/command_kit/exception_handler.rb +4 -0
- data/lib/command_kit/help.rb +7 -1
- data/lib/command_kit/help/man.rb +13 -0
- data/lib/command_kit/inflector.rb +2 -0
- data/lib/command_kit/interactive.rb +62 -1
- data/lib/command_kit/main.rb +11 -0
- data/lib/command_kit/options.rb +12 -0
- data/lib/command_kit/options/option.rb +2 -0
- data/lib/command_kit/options/option_value.rb +2 -0
- data/lib/command_kit/options/parser.rb +29 -0
- data/lib/command_kit/options/quiet.rb +3 -0
- data/lib/command_kit/options/verbose.rb +5 -0
- data/lib/command_kit/options/version.rb +6 -0
- data/lib/command_kit/os.rb +6 -0
- data/lib/command_kit/pager.rb +27 -0
- data/lib/command_kit/printing.rb +23 -0
- data/lib/command_kit/printing/indent.rb +23 -0
- data/lib/command_kit/program_name.rb +7 -0
- data/lib/command_kit/stdio.rb +24 -0
- data/lib/command_kit/terminal.rb +12 -0
- data/lib/command_kit/usage.rb +14 -0
- data/lib/command_kit/version.rb +1 -1
- data/lib/command_kit/xdg.rb +13 -0
- data/spec/arguments/argument_spec.rb +1 -1
- data/spec/arguments_spec.rb +3 -27
- data/spec/colors_spec.rb +21 -13
- data/spec/command_name_spec.rb +1 -1
- data/spec/command_spec.rb +4 -1
- data/spec/commands/auto_load/subcommand_spec.rb +1 -1
- data/spec/commands/auto_load_spec.rb +1 -1
- data/spec/commands/auto_require_spec.rb +2 -2
- data/spec/commands/help_spec.rb +1 -1
- data/spec/commands/parent_command_spec.rb +1 -1
- data/spec/commands/subcommand_spec.rb +1 -1
- data/spec/commands_spec.rb +1 -1
- data/spec/description_spec.rb +1 -25
- data/spec/env/home_spec.rb +1 -1
- data/spec/env/path_spec.rb +1 -1
- data/spec/examples_spec.rb +1 -25
- data/spec/help/man_spec.rb +1 -1
- data/spec/help_spec.rb +0 -25
- data/spec/inflector_spec.rb +1 -1
- data/spec/main_spec.rb +7 -7
- data/spec/options/option_spec.rb +3 -3
- data/spec/options/option_value_spec.rb +1 -1
- data/spec/options_spec.rb +1 -1
- data/spec/os_spec.rb +1 -1
- data/spec/pager_spec.rb +1 -1
- data/spec/printing/indent_spec.rb +1 -1
- data/spec/printing_spec.rb +10 -2
- data/spec/program_name_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -3
- data/spec/terminal_spec.rb +1 -1
- data/spec/usage_spec.rb +1 -1
- data/spec/xdg_spec.rb +1 -1
- metadata +3 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/commands/auto_load/subcommand'
|
3
3
|
|
4
|
-
describe Commands::AutoLoad::Subcommand do
|
4
|
+
describe CommandKit::Commands::AutoLoad::Subcommand do
|
5
5
|
let(:fixtures_dir) { File.expand_path('../../fixtures',__FILE__) }
|
6
6
|
|
7
7
|
let(:file) { 'test1.rb' }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/commands/auto_load'
|
3
3
|
|
4
|
-
describe Commands::AutoLoad do
|
4
|
+
describe CommandKit::Commands::AutoLoad do
|
5
5
|
let(:fixtures_dir) { File.expand_path('../fixtures',__FILE__) }
|
6
6
|
|
7
7
|
let(:dir) { File.join(fixtures_dir,'test_auto_load','cli','commands') }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/commands/auto_require'
|
3
3
|
|
4
|
-
describe Commands::AutoRequire do
|
4
|
+
describe CommandKit::Commands::AutoRequire do
|
5
5
|
let(:fixtures_dir) { File.expand_path('../fixtures',__FILE__) }
|
6
6
|
let(:lib_dir) { File.join(fixtures_dir,'test_auto_require','lib') }
|
7
7
|
let(:dir) { File.join('test_auto_require','cli','commands') }
|
@@ -126,7 +126,7 @@ describe Commands::AutoRequire do
|
|
126
126
|
|
127
127
|
it "the .commands.default_proc must auto-require commands and return a Subcommand" do
|
128
128
|
expect(command_class.commands[command_name]).to_not be(nil)
|
129
|
-
expect(command_class.commands[command_name]).to be_kind_of(Commands::Subcommand)
|
129
|
+
expect(command_class.commands[command_name]).to be_kind_of(CommandKit::Commands::Subcommand)
|
130
130
|
expect(command_class.commands[command_name].command).to eq(TestAutoRequire::CLI::Commands::Test1)
|
131
131
|
end
|
132
132
|
|
data/spec/commands/help_spec.rb
CHANGED
data/spec/commands_spec.rb
CHANGED
data/spec/description_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/description'
|
3
3
|
|
4
|
-
describe Description do
|
4
|
+
describe CommandKit::Description do
|
5
5
|
module TestDescription
|
6
6
|
class ImplicitCmd
|
7
7
|
include CommandKit::Description
|
@@ -175,29 +175,5 @@ describe Description do
|
|
175
175
|
|
176
176
|
subject.help
|
177
177
|
end
|
178
|
-
|
179
|
-
context "when the superclass defines it's own #help method" do
|
180
|
-
module TestDescription
|
181
|
-
class SuperclassHelpMethod
|
182
|
-
def help
|
183
|
-
puts 'superclass'
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
class InheritedHelpMethod < SuperclassHelpMethod
|
188
|
-
include CommandKit::Description
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
let(:super_command_class) { TestDescription::SuperclassHelpMethod }
|
193
|
-
let(:command_class) { TestDescription::InheritedHelpMethod }
|
194
|
-
|
195
|
-
it "must call the superclass'es #help method first" do
|
196
|
-
expect_any_instance_of(super_command_class).to receive(:help)
|
197
|
-
expect(subject).to receive(:help_description)
|
198
|
-
|
199
|
-
subject.help
|
200
|
-
end
|
201
|
-
end
|
202
178
|
end
|
203
179
|
end
|
data/spec/env/home_spec.rb
CHANGED
data/spec/env/path_spec.rb
CHANGED
data/spec/examples_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/examples'
|
3
3
|
|
4
|
-
describe Examples do
|
4
|
+
describe CommandKit::Examples do
|
5
5
|
module TestExamples
|
6
6
|
class ImplicitCmd
|
7
7
|
include CommandKit::Examples
|
@@ -207,29 +207,5 @@ describe Examples do
|
|
207
207
|
|
208
208
|
subject.help
|
209
209
|
end
|
210
|
-
|
211
|
-
context "when the superclass defines it's own #help method" do
|
212
|
-
module TestDescription
|
213
|
-
class SuperclassHelpMethod
|
214
|
-
def help
|
215
|
-
puts 'superclass'
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
class InheritedHelpMethod < SuperclassHelpMethod
|
220
|
-
include CommandKit::Examples
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
let(:super_command_class) { TestDescription::SuperclassHelpMethod }
|
225
|
-
let(:command_class) { TestDescription::InheritedHelpMethod }
|
226
|
-
|
227
|
-
it "must call the superclass'es #help method first" do
|
228
|
-
expect_any_instance_of(super_command_class).to receive(:help)
|
229
|
-
expect(subject).to receive(:help_examples)
|
230
|
-
|
231
|
-
subject.help
|
232
|
-
end
|
233
|
-
end
|
234
210
|
end
|
235
211
|
end
|
data/spec/help/man_spec.rb
CHANGED
data/spec/help_spec.rb
CHANGED
@@ -90,30 +90,5 @@ describe CommandKit::Help do
|
|
90
90
|
subject.help()
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
94
|
-
context "when the superclass defines it's own #help method" do
|
95
|
-
module TestHelp
|
96
|
-
class SuperclassWithHelp
|
97
|
-
|
98
|
-
def help
|
99
|
-
puts 'superclass'
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
class SubclassOfSuperclassWithHelp < SuperclassWithHelp
|
105
|
-
include CommandKit::Help
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
let(:command_superclass) { TestHelp::SuperclassWithHelp }
|
110
|
-
let(:command_class) { TestHelp::SubclassOfSuperclassWithHelp }
|
111
|
-
|
112
|
-
it "must call the superclass'es #help" do
|
113
|
-
expect_any_instance_of(command_superclass).to receive(:help)
|
114
|
-
|
115
|
-
subject.help()
|
116
|
-
end
|
117
|
-
end
|
118
93
|
end
|
119
94
|
end
|
data/spec/inflector_spec.rb
CHANGED
data/spec/main_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/main'
|
3
3
|
|
4
|
-
describe Main do
|
4
|
+
describe CommandKit::Main do
|
5
5
|
module TestMain
|
6
6
|
class TestCommand
|
7
7
|
include CommandKit::Main
|
@@ -156,16 +156,16 @@ describe Main do
|
|
156
156
|
describe "#main" do
|
157
157
|
subject { command_class.new }
|
158
158
|
|
159
|
-
it "must provide a default #main" do
|
160
|
-
expect(subject).to respond_to(:main)
|
161
|
-
end
|
162
|
-
|
163
159
|
it "must return 0 by default" do
|
164
160
|
expect(subject.main).to eq(0)
|
165
161
|
end
|
166
162
|
|
167
|
-
it "must
|
168
|
-
|
163
|
+
it "must call #run with the given argv" do
|
164
|
+
argv = ["foo", "bar", "baz"]
|
165
|
+
|
166
|
+
expect(subject).to receive(:run).with(*argv)
|
167
|
+
|
168
|
+
subject.main(argv)
|
169
169
|
end
|
170
170
|
|
171
171
|
context "when #run raises SystemExit" do
|
data/spec/options/option_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'command_kit/options/option'
|
3
3
|
|
4
|
-
describe Options::Option do
|
4
|
+
describe CommandKit::Options::Option do
|
5
5
|
let(:name) { :foo }
|
6
6
|
let(:short) { nil }
|
7
7
|
let(:long) { '--foo' }
|
@@ -82,7 +82,7 @@ describe Options::Option do
|
|
82
82
|
subject { described_class.new(name, value: {type: type}, desc: desc) }
|
83
83
|
|
84
84
|
it "must initialize #value" do
|
85
|
-
expect(subject.value).to be_kind_of(Options::OptionValue)
|
85
|
+
expect(subject.value).to be_kind_of(CommandKit::Options::OptionValue)
|
86
86
|
expect(subject.value.type).to eq(type)
|
87
87
|
end
|
88
88
|
end
|
@@ -91,7 +91,7 @@ describe Options::Option do
|
|
91
91
|
subject { described_class.new(name, value: true, desc: desc) }
|
92
92
|
|
93
93
|
it "must initialize #value with defaults" do
|
94
|
-
expect(subject.value).to be_kind_of(Options::OptionValue)
|
94
|
+
expect(subject.value).to be_kind_of(CommandKit::Options::OptionValue)
|
95
95
|
expect(subject.value.type).to eq(String)
|
96
96
|
expect(subject.value.required?).to be(true)
|
97
97
|
expect(subject.value.usage).to eq('STR')
|
data/spec/options_spec.rb
CHANGED
data/spec/os_spec.rb
CHANGED
data/spec/pager_spec.rb
CHANGED
data/spec/printing_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'command_kit/printing'
|
|
3
3
|
|
4
4
|
require 'stringio'
|
5
5
|
|
6
|
-
describe Printing do
|
6
|
+
describe CommandKit::Printing do
|
7
7
|
module TestPrinting
|
8
8
|
class TestCmd
|
9
9
|
|
@@ -14,11 +14,19 @@ describe Printing do
|
|
14
14
|
|
15
15
|
let(:command_class) { TestPrinting::TestCmd }
|
16
16
|
subject { command_class.new }
|
17
|
+
|
18
|
+
describe "EOL" do
|
19
|
+
subject { described_class::EOL }
|
20
|
+
|
21
|
+
it "must equal $/" do
|
22
|
+
expect(subject).to eq($/)
|
23
|
+
end
|
24
|
+
end
|
17
25
|
|
18
26
|
describe ".included" do
|
19
27
|
subject { command_class }
|
20
28
|
|
21
|
-
it { expect(command_class).to include(Stdio) }
|
29
|
+
it { expect(command_class).to include(CommandKit::Stdio) }
|
22
30
|
end
|
23
31
|
|
24
32
|
let(:nl) { $/ }
|
data/spec/program_name_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/terminal_spec.rb
CHANGED
data/spec/usage_spec.rb
CHANGED
data/spec/xdg_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: command_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ files:
|
|
134
134
|
- spec/terminal_spec.rb
|
135
135
|
- spec/usage_spec.rb
|
136
136
|
- spec/xdg_spec.rb
|
137
|
-
homepage: https://github.com/postmodern/command_kit#readme
|
137
|
+
homepage: https://github.com/postmodern/command_kit.rb#readme
|
138
138
|
licenses:
|
139
139
|
- MIT
|
140
140
|
metadata: {}
|