command_kit 0.4.1 → 0.5.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 +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/.rubocop.yml +7 -1
- data/ChangeLog.md +11 -0
- data/Gemfile +2 -0
- data/README.md +3 -0
- data/Rakefile +2 -0
- data/command_kit.gemspec +8 -6
- data/lib/command_kit/arguments/argument.rb +3 -1
- data/lib/command_kit/arguments/argument_value.rb +2 -0
- data/lib/command_kit/arguments.rb +5 -5
- data/lib/command_kit/bug_report.rb +4 -2
- data/lib/command_kit/colors.rb +2 -2
- data/lib/command_kit/command.rb +13 -11
- data/lib/command_kit/command_name.rb +3 -1
- data/lib/command_kit/commands/auto_load/subcommand.rb +3 -1
- data/lib/command_kit/commands/auto_load.rb +3 -3
- data/lib/command_kit/commands/auto_require.rb +5 -3
- data/lib/command_kit/commands/command.rb +4 -2
- data/lib/command_kit/commands/help.rb +2 -2
- data/lib/command_kit/commands/parent_command.rb +2 -0
- data/lib/command_kit/commands/subcommand.rb +2 -0
- data/lib/command_kit/commands.rb +8 -8
- data/lib/command_kit/completion/install.rb +277 -0
- data/lib/command_kit/description.rb +3 -1
- data/lib/command_kit/edit.rb +1 -1
- data/lib/command_kit/env/home.rb +1 -1
- data/lib/command_kit/env/path.rb +1 -1
- data/lib/command_kit/env/prefix.rb +41 -0
- data/lib/command_kit/env/shell.rb +58 -0
- data/lib/command_kit/env.rb +2 -0
- data/lib/command_kit/examples.rb +4 -2
- data/lib/command_kit/exception_handler.rb +4 -2
- data/lib/command_kit/file_utils.rb +2 -0
- data/lib/command_kit/help/man.rb +4 -4
- data/lib/command_kit/help.rb +2 -0
- data/lib/command_kit/interactive.rb +1 -1
- data/lib/command_kit/main.rb +2 -0
- data/lib/command_kit/open_app.rb +4 -2
- data/lib/command_kit/options/option.rb +3 -1
- data/lib/command_kit/options/option_value.rb +2 -2
- data/lib/command_kit/options/parser.rb +3 -3
- data/lib/command_kit/options/quiet.rb +3 -1
- data/lib/command_kit/options/verbose.rb +3 -1
- data/lib/command_kit/options/version.rb +3 -1
- data/lib/command_kit/options.rb +5 -3
- data/lib/command_kit/os/linux.rb +3 -1
- data/lib/command_kit/os.rb +2 -0
- data/lib/command_kit/package_manager.rb +6 -4
- data/lib/command_kit/pager.rb +4 -4
- data/lib/command_kit/printing/fields.rb +3 -1
- data/lib/command_kit/printing/indent.rb +2 -0
- data/lib/command_kit/printing/lists.rb +1 -1
- data/lib/command_kit/printing/tables/border_style.rb +2 -0
- data/lib/command_kit/printing/tables/row_builder.rb +3 -1
- data/lib/command_kit/printing/tables/style.rb +1 -1
- data/lib/command_kit/printing/tables/table_builder.rb +3 -1
- data/lib/command_kit/printing/tables.rb +4 -4
- data/lib/command_kit/printing.rb +1 -1
- data/lib/command_kit/program_name.rb +2 -0
- data/lib/command_kit/stdio.rb +2 -0
- data/lib/command_kit/sudo.rb +1 -1
- data/lib/command_kit/terminal.rb +4 -2
- data/lib/command_kit/usage.rb +4 -2
- data/lib/command_kit/version.rb +3 -1
- data/lib/command_kit/xdg.rb +4 -2
- data/lib/command_kit.rb +4 -2
- metadata +5 -65
- data/spec/arguments/argument_spec.rb +0 -133
- data/spec/arguments/argument_value_spec.rb +0 -66
- data/spec/arguments_spec.rb +0 -279
- data/spec/bug_report_spec.rb +0 -266
- data/spec/colors_spec.rb +0 -771
- data/spec/command_kit_spec.rb +0 -8
- data/spec/command_name_spec.rb +0 -130
- data/spec/command_spec.rb +0 -123
- data/spec/commands/auto_load/subcommand_spec.rb +0 -82
- data/spec/commands/auto_load_spec.rb +0 -159
- data/spec/commands/auto_require_spec.rb +0 -142
- data/spec/commands/fixtures/test_auto_load/cli/commands/test1.rb +0 -10
- data/spec/commands/fixtures/test_auto_load/cli/commands/test2.rb +0 -10
- data/spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb +0 -10
- data/spec/commands/help_spec.rb +0 -66
- data/spec/commands/parent_command_spec.rb +0 -40
- data/spec/commands/subcommand_spec.rb +0 -99
- data/spec/commands_spec.rb +0 -865
- data/spec/description_spec.rb +0 -179
- data/spec/edit_spec.rb +0 -72
- data/spec/env/home_spec.rb +0 -46
- data/spec/env/path_spec.rb +0 -84
- data/spec/env_spec.rb +0 -123
- data/spec/examples_spec.rb +0 -211
- data/spec/exception_handler_spec.rb +0 -103
- data/spec/file_utils_spec.rb +0 -59
- data/spec/fixtures/template.erb +0 -5
- data/spec/help/man_spec.rb +0 -345
- data/spec/help_spec.rb +0 -94
- data/spec/inflector_spec.rb +0 -166
- data/spec/interactive_spec.rb +0 -415
- data/spec/main_spec.rb +0 -179
- data/spec/man_spec.rb +0 -46
- data/spec/open_app_spec.rb +0 -85
- data/spec/options/option_spec.rb +0 -343
- data/spec/options/option_value_spec.rb +0 -171
- data/spec/options/parser_spec.rb +0 -274
- data/spec/options/quiet_spec.rb +0 -51
- data/spec/options/verbose_spec.rb +0 -51
- data/spec/options/version_spec.rb +0 -146
- data/spec/options_spec.rb +0 -465
- data/spec/os/linux_spec.rb +0 -164
- data/spec/os_spec.rb +0 -233
- data/spec/package_manager_spec.rb +0 -806
- data/spec/pager_spec.rb +0 -217
- data/spec/printing/fields_spec.rb +0 -167
- data/spec/printing/indent_spec.rb +0 -132
- data/spec/printing/lists_spec.rb +0 -99
- data/spec/printing/tables/border_style.rb +0 -43
- data/spec/printing/tables/cell_builer_spec.rb +0 -135
- data/spec/printing/tables/row_builder_spec.rb +0 -165
- data/spec/printing/tables/style_spec.rb +0 -377
- data/spec/printing/tables/table_builder_spec.rb +0 -252
- data/spec/printing/tables/table_formatter_spec.rb +0 -1190
- data/spec/printing/tables_spec.rb +0 -1069
- data/spec/printing_spec.rb +0 -106
- data/spec/program_name_spec.rb +0 -70
- data/spec/spec_helper.rb +0 -3
- data/spec/stdio_spec.rb +0 -264
- data/spec/sudo_spec.rb +0 -51
- data/spec/terminal_spec.rb +0 -231
- data/spec/usage_spec.rb +0 -237
- data/spec/xdg_spec.rb +0 -191
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../env'
|
4
|
+
|
5
|
+
module CommandKit
|
6
|
+
module Env
|
7
|
+
#
|
8
|
+
# Methods related to the `PREFIX` environment variable.
|
9
|
+
#
|
10
|
+
# ## Environment Variables
|
11
|
+
#
|
12
|
+
# * `PREFIX` - The optional root prefix of the file-system.
|
13
|
+
#
|
14
|
+
# @since 0.5.0
|
15
|
+
#
|
16
|
+
module Prefix
|
17
|
+
include Env
|
18
|
+
|
19
|
+
# The root of the file-system.
|
20
|
+
#
|
21
|
+
# @return [String]
|
22
|
+
# The `PREFIX` environment variable, or `/` if no `PREFIX` environment
|
23
|
+
# variable is given.
|
24
|
+
attr_reader :root
|
25
|
+
|
26
|
+
#
|
27
|
+
# Initialize {#root} based on the `PREFIX` environment
|
28
|
+
#
|
29
|
+
# @param [Hash{Symbol => Object}] kwargs
|
30
|
+
# Additional keyword arguments.
|
31
|
+
#
|
32
|
+
# @api public
|
33
|
+
#
|
34
|
+
def initialize(**kwargs)
|
35
|
+
super(**kwargs)
|
36
|
+
|
37
|
+
@root = env.fetch('PREFIX','/')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../env'
|
4
|
+
|
5
|
+
module CommandKit
|
6
|
+
module Env
|
7
|
+
#
|
8
|
+
# Methods related to the `SHELL` environment variable.
|
9
|
+
#
|
10
|
+
# ## Environment Variables
|
11
|
+
#
|
12
|
+
# * `SHELL` - The current shell.
|
13
|
+
#
|
14
|
+
# @since 0.5.0
|
15
|
+
#
|
16
|
+
module Shell
|
17
|
+
include Env
|
18
|
+
|
19
|
+
# The current shell.
|
20
|
+
#
|
21
|
+
# @return [String, nil]
|
22
|
+
attr_reader :shell
|
23
|
+
|
24
|
+
# The current shell type.
|
25
|
+
#
|
26
|
+
# @return [:bash, :zsh, :fish, :dash, :mksh, :ksh, :tcsh, :csh, :sh, nil]
|
27
|
+
attr_reader :shell_type
|
28
|
+
|
29
|
+
#
|
30
|
+
# Initialize {#shell} and {#shell_type} based on the `SHELL` environment
|
31
|
+
# variable.
|
32
|
+
#
|
33
|
+
# @param [Hash{Symbol => Object}] kwargs
|
34
|
+
# Additional keyword arguments.
|
35
|
+
#
|
36
|
+
# @api public
|
37
|
+
#
|
38
|
+
def initialize(**kwargs)
|
39
|
+
super(**kwargs)
|
40
|
+
|
41
|
+
@shell = env['SHELL']
|
42
|
+
@shell_type = if @shell
|
43
|
+
case File.basename(@shell)
|
44
|
+
when /bash/ then :bash
|
45
|
+
when /zsh/ then :zsh
|
46
|
+
when /fish/ then :fish
|
47
|
+
when /dash/ then :dash
|
48
|
+
when /mksh/ then :mksh
|
49
|
+
when /ksh/ then :ksh
|
50
|
+
when /tcsh/ then :tcsh
|
51
|
+
when /csh/ then :csh
|
52
|
+
when /sh/ then :sh
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/command_kit/env.rb
CHANGED
data/lib/command_kit/examples.rb
CHANGED
data/lib/command_kit/help/man.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative '../command_name'
|
4
|
+
require_relative '../help'
|
5
|
+
require_relative '../stdio'
|
6
|
+
require_relative '../man'
|
7
7
|
|
8
8
|
module CommandKit
|
9
9
|
module Help
|
data/lib/command_kit/help.rb
CHANGED
data/lib/command_kit/main.rb
CHANGED
data/lib/command_kit/open_app.rb
CHANGED
data/lib/command_kit/options.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'arguments'
|
4
|
+
require_relative 'options/option'
|
5
|
+
require_relative 'options/parser'
|
4
6
|
|
5
7
|
module CommandKit
|
6
8
|
#
|
data/lib/command_kit/os/linux.rb
CHANGED
data/lib/command_kit/os.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'os'
|
4
|
+
require_relative 'os/linux'
|
5
|
+
require_relative 'env/path'
|
6
|
+
require_relative 'sudo'
|
5
7
|
|
6
8
|
module CommandKit
|
7
9
|
#
|
data/lib/command_kit/pager.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'env'
|
4
|
+
require_relative 'env/path'
|
5
|
+
require_relative 'stdio'
|
6
|
+
require_relative 'terminal'
|
7
7
|
|
8
8
|
require 'shellwords'
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require_relative 'indent'
|
4
|
+
require_relative 'tables/table_builder'
|
5
|
+
require_relative 'tables/style'
|
6
|
+
require_relative 'tables/table_formatter'
|
7
7
|
|
8
8
|
module CommandKit
|
9
9
|
module Printing
|
data/lib/command_kit/printing.rb
CHANGED
data/lib/command_kit/stdio.rb
CHANGED
data/lib/command_kit/sudo.rb
CHANGED
data/lib/command_kit/terminal.rb
CHANGED
data/lib/command_kit/usage.rb
CHANGED
data/lib/command_kit/version.rb
CHANGED
data/lib/command_kit/xdg.rb
CHANGED
data/lib/command_kit.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.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,11 +73,14 @@ files:
|
|
73
73
|
- lib/command_kit/commands/help.rb
|
74
74
|
- lib/command_kit/commands/parent_command.rb
|
75
75
|
- lib/command_kit/commands/subcommand.rb
|
76
|
+
- lib/command_kit/completion/install.rb
|
76
77
|
- lib/command_kit/description.rb
|
77
78
|
- lib/command_kit/edit.rb
|
78
79
|
- lib/command_kit/env.rb
|
79
80
|
- lib/command_kit/env/home.rb
|
80
81
|
- lib/command_kit/env/path.rb
|
82
|
+
- lib/command_kit/env/prefix.rb
|
83
|
+
- lib/command_kit/env/shell.rb
|
81
84
|
- lib/command_kit/examples.rb
|
82
85
|
- lib/command_kit/exception_handler.rb
|
83
86
|
- lib/command_kit/file_utils.rb
|
@@ -117,69 +120,6 @@ files:
|
|
117
120
|
- lib/command_kit/usage.rb
|
118
121
|
- lib/command_kit/version.rb
|
119
122
|
- lib/command_kit/xdg.rb
|
120
|
-
- spec/arguments/argument_spec.rb
|
121
|
-
- spec/arguments/argument_value_spec.rb
|
122
|
-
- spec/arguments_spec.rb
|
123
|
-
- spec/bug_report_spec.rb
|
124
|
-
- spec/colors_spec.rb
|
125
|
-
- spec/command_kit_spec.rb
|
126
|
-
- spec/command_name_spec.rb
|
127
|
-
- spec/command_spec.rb
|
128
|
-
- spec/commands/auto_load/subcommand_spec.rb
|
129
|
-
- spec/commands/auto_load_spec.rb
|
130
|
-
- spec/commands/auto_require_spec.rb
|
131
|
-
- spec/commands/fixtures/test_auto_load/cli/commands/test1.rb
|
132
|
-
- spec/commands/fixtures/test_auto_load/cli/commands/test2.rb
|
133
|
-
- spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb
|
134
|
-
- spec/commands/help_spec.rb
|
135
|
-
- spec/commands/parent_command_spec.rb
|
136
|
-
- spec/commands/subcommand_spec.rb
|
137
|
-
- spec/commands_spec.rb
|
138
|
-
- spec/description_spec.rb
|
139
|
-
- spec/edit_spec.rb
|
140
|
-
- spec/env/home_spec.rb
|
141
|
-
- spec/env/path_spec.rb
|
142
|
-
- spec/env_spec.rb
|
143
|
-
- spec/examples_spec.rb
|
144
|
-
- spec/exception_handler_spec.rb
|
145
|
-
- spec/file_utils_spec.rb
|
146
|
-
- spec/fixtures/template.erb
|
147
|
-
- spec/help/man_spec.rb
|
148
|
-
- spec/help_spec.rb
|
149
|
-
- spec/inflector_spec.rb
|
150
|
-
- spec/interactive_spec.rb
|
151
|
-
- spec/main_spec.rb
|
152
|
-
- spec/man_spec.rb
|
153
|
-
- spec/open_app_spec.rb
|
154
|
-
- spec/options/option_spec.rb
|
155
|
-
- spec/options/option_value_spec.rb
|
156
|
-
- spec/options/parser_spec.rb
|
157
|
-
- spec/options/quiet_spec.rb
|
158
|
-
- spec/options/verbose_spec.rb
|
159
|
-
- spec/options/version_spec.rb
|
160
|
-
- spec/options_spec.rb
|
161
|
-
- spec/os/linux_spec.rb
|
162
|
-
- spec/os_spec.rb
|
163
|
-
- spec/package_manager_spec.rb
|
164
|
-
- spec/pager_spec.rb
|
165
|
-
- spec/printing/fields_spec.rb
|
166
|
-
- spec/printing/indent_spec.rb
|
167
|
-
- spec/printing/lists_spec.rb
|
168
|
-
- spec/printing/tables/border_style.rb
|
169
|
-
- spec/printing/tables/cell_builer_spec.rb
|
170
|
-
- spec/printing/tables/row_builder_spec.rb
|
171
|
-
- spec/printing/tables/style_spec.rb
|
172
|
-
- spec/printing/tables/table_builder_spec.rb
|
173
|
-
- spec/printing/tables/table_formatter_spec.rb
|
174
|
-
- spec/printing/tables_spec.rb
|
175
|
-
- spec/printing_spec.rb
|
176
|
-
- spec/program_name_spec.rb
|
177
|
-
- spec/spec_helper.rb
|
178
|
-
- spec/stdio_spec.rb
|
179
|
-
- spec/sudo_spec.rb
|
180
|
-
- spec/terminal_spec.rb
|
181
|
-
- spec/usage_spec.rb
|
182
|
-
- spec/xdg_spec.rb
|
183
123
|
homepage: https://github.com/postmodern/command_kit.rb#readme
|
184
124
|
licenses:
|
185
125
|
- MIT
|