command_kit 0.4.0 → 0.5.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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +2 -0
  3. data/.rubocop.yml +3 -0
  4. data/ChangeLog.md +18 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +4 -1
  7. data/command_kit.gemspec +7 -2
  8. data/examples/subcommands/cli/config/get.rb +47 -0
  9. data/examples/subcommands/cli/config/set.rb +44 -0
  10. data/examples/subcommands/cli/config.rb +23 -0
  11. data/examples/subcommands/cli/list.rb +35 -0
  12. data/examples/subcommands/cli/update.rb +47 -0
  13. data/examples/subcommands/cli.rb +55 -0
  14. data/lib/command_kit/completion/install.rb +276 -0
  15. data/lib/command_kit/env/home.rb +1 -1
  16. data/lib/command_kit/env/prefix.rb +41 -0
  17. data/lib/command_kit/env/shell.rb +58 -0
  18. data/lib/command_kit/inflector.rb +1 -1
  19. data/lib/command_kit/options/parser.rb +1 -1
  20. data/lib/command_kit/os/linux.rb +1 -1
  21. data/lib/command_kit/os.rb +1 -1
  22. data/lib/command_kit/printing/tables/table_formatter.rb +2 -2
  23. data/lib/command_kit/version.rb +1 -1
  24. data/lib/command_kit/xdg.rb +1 -1
  25. metadata +12 -66
  26. data/spec/arguments/argument_spec.rb +0 -133
  27. data/spec/arguments/argument_value_spec.rb +0 -66
  28. data/spec/arguments_spec.rb +0 -279
  29. data/spec/bug_report_spec.rb +0 -266
  30. data/spec/colors_spec.rb +0 -771
  31. data/spec/command_kit_spec.rb +0 -8
  32. data/spec/command_name_spec.rb +0 -130
  33. data/spec/command_spec.rb +0 -123
  34. data/spec/commands/auto_load/subcommand_spec.rb +0 -82
  35. data/spec/commands/auto_load_spec.rb +0 -159
  36. data/spec/commands/auto_require_spec.rb +0 -142
  37. data/spec/commands/fixtures/test_auto_load/cli/commands/test1.rb +0 -10
  38. data/spec/commands/fixtures/test_auto_load/cli/commands/test2.rb +0 -10
  39. data/spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb +0 -10
  40. data/spec/commands/help_spec.rb +0 -66
  41. data/spec/commands/parent_command_spec.rb +0 -40
  42. data/spec/commands/subcommand_spec.rb +0 -99
  43. data/spec/commands_spec.rb +0 -839
  44. data/spec/description_spec.rb +0 -179
  45. data/spec/edit_spec.rb +0 -72
  46. data/spec/env/home_spec.rb +0 -46
  47. data/spec/env/path_spec.rb +0 -84
  48. data/spec/env_spec.rb +0 -123
  49. data/spec/examples_spec.rb +0 -211
  50. data/spec/exception_handler_spec.rb +0 -103
  51. data/spec/file_utils_spec.rb +0 -59
  52. data/spec/fixtures/template.erb +0 -5
  53. data/spec/help/man_spec.rb +0 -345
  54. data/spec/help_spec.rb +0 -94
  55. data/spec/inflector_spec.rb +0 -166
  56. data/spec/interactive_spec.rb +0 -415
  57. data/spec/main_spec.rb +0 -179
  58. data/spec/man_spec.rb +0 -46
  59. data/spec/open_app_spec.rb +0 -85
  60. data/spec/options/option_spec.rb +0 -343
  61. data/spec/options/option_value_spec.rb +0 -171
  62. data/spec/options/parser_spec.rb +0 -255
  63. data/spec/options/quiet_spec.rb +0 -51
  64. data/spec/options/verbose_spec.rb +0 -51
  65. data/spec/options/version_spec.rb +0 -146
  66. data/spec/options_spec.rb +0 -465
  67. data/spec/os/linux_spec.rb +0 -164
  68. data/spec/os_spec.rb +0 -233
  69. data/spec/package_manager_spec.rb +0 -806
  70. data/spec/pager_spec.rb +0 -217
  71. data/spec/printing/fields_spec.rb +0 -167
  72. data/spec/printing/indent_spec.rb +0 -132
  73. data/spec/printing/lists_spec.rb +0 -99
  74. data/spec/printing/tables/border_style.rb +0 -43
  75. data/spec/printing/tables/cell_builer_spec.rb +0 -135
  76. data/spec/printing/tables/row_builder_spec.rb +0 -165
  77. data/spec/printing/tables/style_spec.rb +0 -377
  78. data/spec/printing/tables/table_builder_spec.rb +0 -252
  79. data/spec/printing/tables/table_formatter_spec.rb +0 -1180
  80. data/spec/printing/tables_spec.rb +0 -1069
  81. data/spec/printing_spec.rb +0 -106
  82. data/spec/program_name_spec.rb +0 -70
  83. data/spec/spec_helper.rb +0 -3
  84. data/spec/stdio_spec.rb +0 -264
  85. data/spec/sudo_spec.rb +0 -51
  86. data/spec/terminal_spec.rb +0 -231
  87. data/spec/usage_spec.rb +0 -237
  88. 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