command_kit 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +6 -0
  3. data/README.md +3 -0
  4. data/command_kit.gemspec +7 -2
  5. data/lib/command_kit/completion/install.rb +276 -0
  6. data/lib/command_kit/env/prefix.rb +41 -0
  7. data/lib/command_kit/env/shell.rb +58 -0
  8. data/lib/command_kit/version.rb +1 -1
  9. metadata +4 -64
  10. data/spec/arguments/argument_spec.rb +0 -133
  11. data/spec/arguments/argument_value_spec.rb +0 -66
  12. data/spec/arguments_spec.rb +0 -279
  13. data/spec/bug_report_spec.rb +0 -266
  14. data/spec/colors_spec.rb +0 -771
  15. data/spec/command_kit_spec.rb +0 -8
  16. data/spec/command_name_spec.rb +0 -130
  17. data/spec/command_spec.rb +0 -123
  18. data/spec/commands/auto_load/subcommand_spec.rb +0 -82
  19. data/spec/commands/auto_load_spec.rb +0 -159
  20. data/spec/commands/auto_require_spec.rb +0 -142
  21. data/spec/commands/fixtures/test_auto_load/cli/commands/test1.rb +0 -10
  22. data/spec/commands/fixtures/test_auto_load/cli/commands/test2.rb +0 -10
  23. data/spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb +0 -10
  24. data/spec/commands/help_spec.rb +0 -66
  25. data/spec/commands/parent_command_spec.rb +0 -40
  26. data/spec/commands/subcommand_spec.rb +0 -99
  27. data/spec/commands_spec.rb +0 -865
  28. data/spec/description_spec.rb +0 -179
  29. data/spec/edit_spec.rb +0 -72
  30. data/spec/env/home_spec.rb +0 -46
  31. data/spec/env/path_spec.rb +0 -84
  32. data/spec/env_spec.rb +0 -123
  33. data/spec/examples_spec.rb +0 -211
  34. data/spec/exception_handler_spec.rb +0 -103
  35. data/spec/file_utils_spec.rb +0 -59
  36. data/spec/fixtures/template.erb +0 -5
  37. data/spec/help/man_spec.rb +0 -345
  38. data/spec/help_spec.rb +0 -94
  39. data/spec/inflector_spec.rb +0 -166
  40. data/spec/interactive_spec.rb +0 -415
  41. data/spec/main_spec.rb +0 -179
  42. data/spec/man_spec.rb +0 -46
  43. data/spec/open_app_spec.rb +0 -85
  44. data/spec/options/option_spec.rb +0 -343
  45. data/spec/options/option_value_spec.rb +0 -171
  46. data/spec/options/parser_spec.rb +0 -274
  47. data/spec/options/quiet_spec.rb +0 -51
  48. data/spec/options/verbose_spec.rb +0 -51
  49. data/spec/options/version_spec.rb +0 -146
  50. data/spec/options_spec.rb +0 -465
  51. data/spec/os/linux_spec.rb +0 -164
  52. data/spec/os_spec.rb +0 -233
  53. data/spec/package_manager_spec.rb +0 -806
  54. data/spec/pager_spec.rb +0 -217
  55. data/spec/printing/fields_spec.rb +0 -167
  56. data/spec/printing/indent_spec.rb +0 -132
  57. data/spec/printing/lists_spec.rb +0 -99
  58. data/spec/printing/tables/border_style.rb +0 -43
  59. data/spec/printing/tables/cell_builer_spec.rb +0 -135
  60. data/spec/printing/tables/row_builder_spec.rb +0 -165
  61. data/spec/printing/tables/style_spec.rb +0 -377
  62. data/spec/printing/tables/table_builder_spec.rb +0 -252
  63. data/spec/printing/tables/table_formatter_spec.rb +0 -1190
  64. data/spec/printing/tables_spec.rb +0 -1069
  65. data/spec/printing_spec.rb +0 -106
  66. data/spec/program_name_spec.rb +0 -70
  67. data/spec/spec_helper.rb +0 -3
  68. data/spec/stdio_spec.rb +0 -264
  69. data/spec/sudo_spec.rb +0 -51
  70. data/spec/terminal_spec.rb +0 -231
  71. data/spec/usage_spec.rb +0 -237
  72. data/spec/xdg_spec.rb +0 -191
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_kit/commands/help'
3
- require 'command_kit/commands'
4
-
5
- describe CommandKit::Commands::Help do
6
- module TestHelpCommand
7
- class CLI
8
- include CommandKit::Commands
9
-
10
- class Test < CommandKit::Command
11
- end
12
-
13
- class TestWithoutHelp
14
- end
15
-
16
- command Test
17
- command 'test-without-help', TestWithoutHelp
18
- end
19
- end
20
-
21
- let(:parent_command_class) { TestHelpCommand::CLI }
22
- let(:parent_command) { parent_command_class.new }
23
- let(:command_class) { CommandKit::Commands::Help }
24
-
25
- subject { command_class.new(parent_command: parent_command) }
26
-
27
- describe ".run" do
28
- context "when giving no arguments" do
29
- it "must call the parent command's #help method" do
30
- expect(parent_command).to receive(:help).with(no_args)
31
-
32
- subject.run
33
- end
34
- end
35
-
36
- context "when given a command name" do
37
- let(:command) { 'test' }
38
-
39
- it "must lookup the command and call it's #help method" do
40
- expect_any_instance_of(parent_command_class::Test).to receive(:help)
41
-
42
- subject.run(command)
43
- end
44
-
45
- context "but the command does not define a #help method" do
46
- let(:command) { 'test-without-help' }
47
-
48
- it do
49
- expect { subject.run(command) }.to raise_error(TypeError)
50
- end
51
- end
52
-
53
- context "but the command name is invalid" do
54
- let(:command) { 'xxx' }
55
-
56
- it "must print an error message and exit with 1" do
57
- expect(subject).to receive(:exit).with(1)
58
-
59
- expect { subject.run(command) }.to output(
60
- "#{subject.command_name}: unknown command: #{command}#{$/}"
61
- ).to_stderr
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_kit/commands'
3
- require 'command_kit/commands/parent_command'
4
-
5
- describe CommandKit::Commands::ParentCommand do
6
- module TestParentCommand
7
- class TestCommands
8
-
9
- include CommandKit::Commands
10
-
11
- class Test < CommandKit::Command
12
- include CommandKit::Commands::ParentCommand
13
- end
14
-
15
- command Test
16
-
17
- end
18
- end
19
-
20
- let(:parent_command_class) { TestParentCommand::TestCommands }
21
- let(:command_class) { TestParentCommand::TestCommands::Test }
22
-
23
- describe "#initialize" do
24
- context "when given a parent_command: keyword argument" do
25
- let(:parent_command) { parent_command_class.new }
26
-
27
- subject { command_class.new(parent_command: parent_command) }
28
-
29
- it "must initialize #parent_command" do
30
- expect(subject.parent_command).to be(parent_command)
31
- end
32
- end
33
-
34
- context "when the parent_command: keyword argument is not given" do
35
- it do
36
- expect { command_class.new }.to raise_error(ArgumentError)
37
- end
38
- end
39
- end
40
- end
@@ -1,99 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_kit/commands/subcommand'
3
- require 'command_kit/command'
4
-
5
- describe CommandKit::Commands::Subcommand do
6
- module TestSubcommands
7
- class TestCommand < CommandKit::Command
8
- end
9
-
10
- class TestCommandWithoutDescription
11
- end
12
-
13
- class TestCommandWithASentenceFragmentDescription
14
- include CommandKit::Description
15
-
16
- description "The quick brown fox"
17
- end
18
-
19
- class TestCommandWithASingleSentenceDescription
20
- include CommandKit::Description
21
-
22
- description "The quick brown fox jumps over the lazy dog."
23
- end
24
-
25
- class TestCommandWithAMultiSentenceDescription
26
- include CommandKit::Description
27
-
28
- description "The quick brown fox jumps over the lazy dog. Foo bar baz."
29
- end
30
- end
31
-
32
- describe "#initialize" do
33
- let(:command_class) { TestSubcommands::TestCommand }
34
-
35
- subject { described_class.new(command_class) }
36
-
37
- it "must initialize the subcommand with a given command class" do
38
- expect(subject.command).to be(command_class)
39
- end
40
-
41
- context "when the command class has no description" do
42
- it "#summary must be nil" do
43
- expect(subject.summary).to be(nil)
44
- end
45
- end
46
-
47
- context "when the command class have a description" do
48
- let(:command_class) { TestSubcommands::TestCommandWithAMultiSentenceDescription }
49
-
50
- it "must extract the summary using .summary" do
51
- expect(subject.summary).to eq(described_class.summary(command_class))
52
- end
53
- end
54
-
55
- context "when given aliases:" do
56
- let(:aliases) { %w[test t] }
57
-
58
- subject { described_class.new(command_class, aliases: aliases) }
59
-
60
- it "must initialize #aliases" do
61
- expect(subject.aliases).to eq(aliases)
62
- end
63
- end
64
- end
65
-
66
- describe ".summary" do
67
- subject { described_class.summary(command_class) }
68
-
69
- context "when the command class does respond_to?(:description)" do
70
- let(:command_class) { TestSubcommands::TestCommandWithoutDescription }
71
-
72
- it { expect(subject).to be(nil) }
73
- end
74
-
75
- context "when the command class has a sentence fragment description" do
76
- let(:command_class) { TestSubcommands::TestCommandWithASentenceFragmentDescription }
77
-
78
- it "must return the sentence fragment" do
79
- expect(subject).to eq(command_class.description)
80
- end
81
- end
82
-
83
- context "when the command class has a single sentence description" do
84
- let(:command_class) { TestSubcommands::TestCommandWithASingleSentenceDescription }
85
-
86
- it "must return the single sentence without the terminating period" do
87
- expect(subject).to eq(command_class.description.chomp('.'))
88
- end
89
- end
90
-
91
- context "when the command class has a multi-sentence description" do
92
- let(:command_class) { TestSubcommands::TestCommandWithAMultiSentenceDescription }
93
-
94
- it "must extract the first sentence, without the terminating period" do
95
- expect(subject).to eq(command_class.description.split(/\.\s*/).first)
96
- end
97
- end
98
- end
99
- end