bashly 0.8.10 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/bin/bashly +2 -2
- data/lib/bashly/cli.rb +2 -3
- data/lib/bashly/commands/add.rb +77 -50
- data/lib/bashly/commands/base.rb +4 -3
- data/lib/bashly/commands/generate.rb +43 -36
- data/lib/bashly/commands/init.rb +10 -9
- data/lib/bashly/commands/preview.rb +4 -4
- data/lib/bashly/commands/validate.rb +8 -7
- data/lib/bashly/concerns/asset_helper.rb +1 -1
- data/lib/bashly/concerns/completions.rb +24 -15
- data/lib/bashly/concerns/renderable.rb +5 -5
- data/lib/bashly/concerns/validation_helpers.rb +20 -12
- data/lib/bashly/config.rb +1 -1
- data/lib/bashly/config_validator.rb +53 -27
- data/lib/bashly/deprecation.rb +9 -7
- data/lib/bashly/exceptions.rb +1 -1
- data/lib/bashly/extensions/array.rb +4 -4
- data/lib/bashly/extensions/file.rb +3 -3
- data/lib/bashly/extensions/string.rb +6 -6
- data/lib/bashly/libraries/base.rb +11 -1
- data/lib/bashly/libraries/completions_function.rb +9 -10
- data/lib/bashly/libraries/completions_script.rb +7 -8
- data/lib/bashly/libraries/completions_yaml.rb +7 -8
- data/lib/bashly/libraries/help.rb +36 -0
- data/lib/bashly/libraries.yml +11 -9
- data/lib/bashly/library.rb +8 -5
- data/lib/bashly/message_strings.rb +1 -1
- data/lib/bashly/refinements/compose_refinements.rb +2 -2
- data/lib/bashly/script/argument.rb +1 -1
- data/lib/bashly/script/base.rb +3 -2
- data/lib/bashly/script/catch_all.rb +6 -4
- data/lib/bashly/script/command.rb +48 -54
- data/lib/bashly/script/environment_variable.rb +5 -5
- data/lib/bashly/script/flag.rb +7 -7
- data/lib/bashly/script/wrapper.rb +6 -5
- data/lib/bashly/settings.rb +30 -27
- data/lib/bashly/templates/help/help_command.sh +30 -0
- data/lib/bashly/templates/lib/colors.sh +2 -2
- data/lib/bashly/templates/lib/config.sh +10 -10
- data/lib/bashly/templates/lib/yaml.sh +9 -9
- data/lib/bashly/templates/settings.yml +3 -0
- data/lib/bashly/templates/test/approvals.bash +36 -12
- data/lib/bashly/templates/test/approve +14 -9
- data/lib/bashly/version.rb +2 -2
- data/lib/bashly/views/command/command_fallback.gtx +9 -6
- data/lib/bashly/views/command/command_filter.gtx +8 -9
- data/lib/bashly/views/command/dependencies_filter.gtx +6 -2
- data/lib/bashly/views/command/fixed_flags_filter.gtx +18 -12
- data/lib/bashly/views/command/inspect_args.gtx +2 -2
- data/lib/bashly/views/command/normalize_input.gtx +1 -1
- data/lib/bashly/views/command/parse_requirements_while.gtx +11 -11
- data/lib/bashly/views/command/run.gtx +16 -13
- data/lib/bashly/views/command/usage_environment_variables.gtx +1 -1
- data/lib/bashly/views/flag/case.gtx +1 -1
- data/lib/bashly/views/flag/case_no_arg.gtx +1 -1
- metadata +10 -8
- data/lib/bashly/libraries/completions.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1139c7453fff329c05879511103b80b6a89a76896a9d0cb3f5cad016d224b15
|
4
|
+
data.tar.gz: acda8a068081a04a32218be7ddfee8cad1612b3dfafd9e1465170fd9cded32db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61247ecd7b928a4babdbf307004424ffa060c567a16b4eb4b062c59e51eb9812f3469981ead958bb4f08aee8cb7ecd86a32a830f6102211012540eac0b878fd4
|
7
|
+
data.tar.gz: 606e5df99d98e9853ed25a7fd516a807a90f1c40d7f19ac2ab1b8f3388a82919dd59af3b291d8de7b866d88cdcb8b1fec7883bd258b80c04f137b1729e58aca1
|
data/README.md
CHANGED
@@ -73,6 +73,13 @@ to contribute, feel free to [open an issue][issues] or
|
|
73
73
|
Visit the *[How to contribute][contributing]* page for more information.
|
74
74
|
|
75
75
|
|
76
|
+
## Stargazers and Forkers
|
77
|
+
|
78
|
+
[![Stargazers repo roster for @DannyBen/bashly](https://reporoster.com/stars/DannyBen/bashly)](https://github.com/DannyBen/bashly/stargazers)
|
79
|
+
|
80
|
+
[![Forkers repo roster for @DannyBen/bashly](https://reporoster.com/forks/DannyBen/bashly)](https://github.com/DannyBen/bashly/network/members)
|
81
|
+
|
82
|
+
|
76
83
|
|
77
84
|
[issues]: https://github.com/DannyBen/bashly/issues
|
78
85
|
[discussions]: https://github.com/DannyBen/bashly/discussions
|
data/bin/bashly
CHANGED
data/lib/bashly/cli.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'mister_bin'
|
2
2
|
|
3
3
|
module Bashly
|
4
|
-
# The CLI class is used by the bashly binary and forwards incoming CLI
|
4
|
+
# The CLI class is used by the bashly binary and forwards incoming CLI
|
5
5
|
# commands to the relevant Bashly::Commands class
|
6
6
|
class CLI
|
7
7
|
def self.runner
|
8
8
|
runner = MisterBin::Runner.new version: Bashly::VERSION,
|
9
|
-
header:
|
9
|
+
header: 'Bashly - Bash CLI Generator',
|
10
10
|
footer: "Help: !txtpur!bashly COMMAND --help!txtrst!\nDocs: !undblu!https://bashly.dannyb.co"
|
11
11
|
|
12
12
|
runner.route 'init', to: Commands::Init
|
@@ -18,5 +18,4 @@ module Bashly
|
|
18
18
|
runner
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
22
21
|
end
|
data/lib/bashly/commands/add.rb
CHANGED
@@ -1,40 +1,61 @@
|
|
1
1
|
module Bashly
|
2
2
|
module Commands
|
3
3
|
class Add < Base
|
4
|
-
help
|
5
|
-
|
6
|
-
usage
|
7
|
-
usage
|
8
|
-
usage
|
9
|
-
usage
|
10
|
-
usage
|
11
|
-
usage
|
12
|
-
usage
|
13
|
-
usage
|
14
|
-
usage
|
15
|
-
usage
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
param
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
4
|
+
help 'Add extra features and customization to your script'
|
5
|
+
|
6
|
+
usage 'bashly add colors [--force]'
|
7
|
+
usage 'bashly add comp FORMAT [OUTPUT --force]'
|
8
|
+
usage 'bashly add config [--force]'
|
9
|
+
usage 'bashly add help [--force]'
|
10
|
+
usage 'bashly add lib [--force]'
|
11
|
+
usage 'bashly add settings [--force]'
|
12
|
+
usage 'bashly add strings [--force]'
|
13
|
+
usage 'bashly add test [--force]'
|
14
|
+
usage 'bashly add validations [--force]'
|
15
|
+
usage 'bashly add yaml [--force]'
|
16
|
+
usage 'bashly add (-h|--help)'
|
17
|
+
|
18
|
+
option '-f --force', 'Overwrite existing files'
|
19
|
+
|
20
|
+
param 'FORMAT', <<~USAGE
|
21
|
+
Output format, can be one of:
|
22
|
+
function : generate a function file to be included in your script.
|
23
|
+
script : generate a standalone bash completions script.
|
24
|
+
yaml : generate a yaml compatible with completely.
|
25
|
+
USAGE
|
26
|
+
|
27
|
+
param 'OUTPUT', <<~USAGE
|
28
|
+
For the 'comp function' command: Name of the generated function.
|
29
|
+
For the 'comp script' or 'comp yaml' commands: path to output file.
|
30
|
+
In all cases, this is optional and will have sensible defaults.
|
31
|
+
USAGE
|
32
|
+
|
33
|
+
command 'colors', 'Add standard functions for printing colorful and formatted text to the lib directory.'
|
34
|
+
command 'comp', 'Generate a bash completions script or function.'
|
35
|
+
command 'config', 'Add standard functions for handling INI files to the lib directory.'
|
36
|
+
command 'help', 'Add a help command, in addition to the standard --help flag.'
|
37
|
+
command 'lib', <<~USAGE
|
38
|
+
Create the lib directory for any additional user scripts.
|
39
|
+
All *.sh scripts in this directory will be included in the final bash script.
|
40
|
+
Note that if you configured a different partials_extension, then the extensions of the files in this directory need to match.
|
41
|
+
USAGE
|
42
|
+
|
43
|
+
command 'settings', 'Copy a sample settings.yml file to your project, allowing you to customize some ' \
|
44
|
+
'bashly options.'
|
45
|
+
|
46
|
+
command 'strings', 'Copy an additional configuration file to your project, allowing you to customize all the ' \
|
47
|
+
'tips and error strings.'
|
48
|
+
|
49
|
+
command 'test', 'Add approval testing.'
|
50
|
+
command 'validations', 'Add argument validation functions to the lib directory.'
|
51
|
+
command 'yaml', 'Add standard functions for reading YAML files to the lib directory.'
|
52
|
+
example 'bashly add strings --force'
|
53
|
+
example 'bashly add comp function'
|
54
|
+
example 'bashly add comp script completions.bash'
|
55
|
+
|
56
|
+
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source files [default: src]'
|
57
|
+
environment 'BASHLY_LIB_DIR', 'The path to use for creating the library files, relative to the source dir ' \
|
58
|
+
'[default: lib]'
|
38
59
|
|
39
60
|
attr_reader :skip_src_check
|
40
61
|
|
@@ -47,9 +68,9 @@ module Bashly
|
|
47
68
|
output = args['OUTPUT']
|
48
69
|
|
49
70
|
case format
|
50
|
-
when
|
51
|
-
when
|
52
|
-
when
|
71
|
+
when 'script' then add_lib 'completions_script', output
|
72
|
+
when 'function' then add_lib 'completions', output
|
73
|
+
when 'yaml' then add_lib 'completions_yaml', output
|
53
74
|
else raise Error, "Unrecognized format: #{format}"
|
54
75
|
end
|
55
76
|
end
|
@@ -58,6 +79,10 @@ module Bashly
|
|
58
79
|
add_lib 'config'
|
59
80
|
end
|
60
81
|
|
82
|
+
def lib_command
|
83
|
+
add_lib 'lib'
|
84
|
+
end
|
85
|
+
|
61
86
|
def settings_command
|
62
87
|
@skip_src_check = true
|
63
88
|
add_lib 'settings'
|
@@ -67,22 +92,22 @@ module Bashly
|
|
67
92
|
add_lib 'strings'
|
68
93
|
end
|
69
94
|
|
70
|
-
def lib_command
|
71
|
-
add_lib 'lib'
|
72
|
-
end
|
73
|
-
|
74
95
|
def test_command
|
75
96
|
add_lib 'test'
|
76
97
|
end
|
77
98
|
|
78
|
-
def
|
79
|
-
add_lib '
|
99
|
+
def help_command
|
100
|
+
add_lib 'help'
|
80
101
|
end
|
81
102
|
|
82
103
|
def validations_command
|
83
104
|
add_lib 'validations'
|
84
105
|
end
|
85
106
|
|
107
|
+
def yaml_command
|
108
|
+
add_lib 'yaml'
|
109
|
+
end
|
110
|
+
|
86
111
|
private
|
87
112
|
|
88
113
|
def add_lib(name, *args)
|
@@ -93,26 +118,28 @@ module Bashly
|
|
93
118
|
files_created += 1 if created
|
94
119
|
end
|
95
120
|
message = library.post_install_message
|
96
|
-
say "\n#{message}" if message
|
121
|
+
say "\n#{message}" if message && files_created.positive?
|
97
122
|
end
|
98
123
|
|
99
124
|
def safe_write(path, content)
|
100
|
-
if !skip_src_check
|
101
|
-
raise InitError,
|
125
|
+
if !skip_src_check && !Dir.exist?(Settings.source_dir)
|
126
|
+
raise InitError, <<~ERROR
|
127
|
+
Directory !txtgrn!#{Settings.source_dir}!txtrst! does not exist
|
128
|
+
Run !txtpur!bashly init!txtrst! first
|
129
|
+
ERROR
|
102
130
|
end
|
103
131
|
|
104
|
-
if File.exist?
|
132
|
+
if File.exist?(path) && !args['--force']
|
105
133
|
say "!txtblu!skipped!txtrst! #{path} (exists)"
|
106
134
|
false
|
107
|
-
|
135
|
+
|
108
136
|
else
|
109
137
|
File.deep_write path, content
|
110
138
|
say "!txtgrn!created!txtrst! #{path}"
|
111
139
|
true
|
112
|
-
|
140
|
+
|
113
141
|
end
|
114
142
|
end
|
115
|
-
|
116
143
|
end
|
117
144
|
end
|
118
145
|
end
|
data/lib/bashly/commands/base.rb
CHANGED
@@ -25,9 +25,10 @@ module Bashly
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def show_deprecations
|
28
|
-
return if config_validator.deprecations.empty?
|
29
|
-
|
30
|
-
|
28
|
+
return if config_validator.deprecations.empty? || ENV['BASHLY_HIDE_DEPRECATIONS']
|
29
|
+
|
30
|
+
messages = config_validator.deprecations.map(&:message).join("\n\n")
|
31
|
+
say! "\n#{messages}\n\n"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -3,34 +3,41 @@ require 'filewatcher'
|
|
3
3
|
module Bashly
|
4
4
|
module Commands
|
5
5
|
class Generate < Base
|
6
|
-
help
|
7
|
-
|
8
|
-
usage
|
9
|
-
usage
|
10
|
-
|
11
|
-
option
|
12
|
-
option
|
13
|
-
option
|
14
|
-
option
|
15
|
-
option
|
16
|
-
option
|
17
|
-
|
18
|
-
environment
|
19
|
-
|
20
|
-
|
21
|
-
environment
|
22
|
-
environment
|
23
|
-
|
6
|
+
help 'Generate the bash script and required files'
|
7
|
+
|
8
|
+
usage 'bashly generate [options]'
|
9
|
+
usage 'bashly generate (-h|--help)'
|
10
|
+
|
11
|
+
option '-f --force', 'Overwrite existing files'
|
12
|
+
option '-q --quiet', 'Disable on-screen progress report'
|
13
|
+
option '-u --upgrade', 'Upgrade all added library functions'
|
14
|
+
option '-w --watch', 'Watch the source directory for changes and regenerate on change'
|
15
|
+
option '-r --wrap FUNCTION', 'Wrap the entire script in a function so it can also be sourced'
|
16
|
+
option '-e --env ENV', 'Force the generation environment (see BASHLY_ENV)'
|
17
|
+
|
18
|
+
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source ' \
|
19
|
+
'files [default: src]'
|
20
|
+
|
21
|
+
environment 'BASHLY_TARGET_DIR', 'The path to use for creating the bash script [default: .]'
|
22
|
+
environment 'BASHLY_LIB_DIR',
|
23
|
+
'The path to use for upgrading library files, relative to the source dir [default: lib]'
|
24
|
+
|
25
|
+
environment 'BASHLY_STRICT', 'When not empty, enable bash strict mode (set -euo pipefail)'
|
26
|
+
environment 'BASHLY_TAB_INDENT',
|
27
|
+
'When not empty, the generated script will use tab indentation instead of spaces ' \
|
28
|
+
'(every 2 leading spaces will be converted to a tab character)'
|
29
|
+
|
30
|
+
environment 'BASHLY_ENV', <<~HELP
|
24
31
|
Set to 'production' or 'development':
|
25
32
|
- production generate a smaller script, without file markers
|
26
33
|
- development generate with file markers
|
27
34
|
|
28
35
|
Can be overridden with --env [default: development]
|
29
|
-
|
36
|
+
HELP
|
30
37
|
|
31
|
-
example
|
32
|
-
example
|
33
|
-
example
|
38
|
+
example 'bashly generate --force'
|
39
|
+
example 'bashly generate --wrap my_function'
|
40
|
+
example 'bashly g -uw'
|
34
41
|
|
35
42
|
attr_reader :watching
|
36
43
|
|
@@ -56,13 +63,12 @@ module Bashly
|
|
56
63
|
|
57
64
|
ensure
|
58
65
|
quiet_say "!txtgrn!waiting\n"
|
59
|
-
|
60
66
|
end
|
61
67
|
end
|
62
68
|
|
63
69
|
def generate
|
64
70
|
with_valid_config do
|
65
|
-
quiet_say
|
71
|
+
quiet_say 'creating !txtgrn!production!txtrst! version' if Settings.production?
|
66
72
|
generate_all_files
|
67
73
|
quiet_say "run !txtpur!#{master_script_path} --help!txtrst! to test your bash script" unless watching
|
68
74
|
end
|
@@ -88,12 +94,11 @@ module Bashly
|
|
88
94
|
def upgrade_libs
|
89
95
|
generated_files.each do |file|
|
90
96
|
content = File.read file
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
97
|
+
next unless content =~ /\[@bashly-upgrade (.+)\]/
|
98
|
+
|
99
|
+
args = $1.split
|
100
|
+
library_name = args.shift
|
101
|
+
upgrade file, library_name, *args
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
@@ -105,7 +110,8 @@ module Bashly
|
|
105
110
|
if Library.exist? library_name
|
106
111
|
upgrade! existing_file, library_name, *args
|
107
112
|
else
|
108
|
-
quiet_say "!txtred!warning!txtrst! not upgrading !txtcyn!#{existing_file}!txtrst!,
|
113
|
+
quiet_say "!txtred!warning!txtrst! not upgrading !txtcyn!#{existing_file}!txtrst!, " \
|
114
|
+
"unknown library '#{library_name}'"
|
109
115
|
end
|
110
116
|
end
|
111
117
|
|
@@ -124,7 +130,8 @@ module Bashly
|
|
124
130
|
def create_user_files
|
125
131
|
quiet_say "creating user files in !txtgrn!#{Settings.source_dir}"
|
126
132
|
|
127
|
-
create_file "#{Settings.source_dir}/initialize.
|
133
|
+
create_file "#{Settings.source_dir}/initialize.#{Settings.partials_extension}",
|
134
|
+
command.render(:default_initialize_script)
|
128
135
|
|
129
136
|
if command.commands.empty?
|
130
137
|
create_root_command_file
|
@@ -140,6 +147,7 @@ module Bashly
|
|
140
147
|
def create_all_command_files
|
141
148
|
command.deep_commands.each do |subcommand|
|
142
149
|
next if subcommand.commands.any?
|
150
|
+
|
143
151
|
file = "#{Settings.source_dir}/#{subcommand.filename}"
|
144
152
|
content = subcommand.render :default_script
|
145
153
|
create_file file, content
|
@@ -147,7 +155,7 @@ module Bashly
|
|
147
155
|
end
|
148
156
|
|
149
157
|
def create_file(file, content)
|
150
|
-
if File.exist?
|
158
|
+
if File.exist?(file) && !args['--force']
|
151
159
|
quiet_say "!txtblu!skipped!txtrst! #{file} (exists)"
|
152
160
|
else
|
153
161
|
File.deep_write file, content
|
@@ -157,12 +165,12 @@ module Bashly
|
|
157
165
|
|
158
166
|
def create_master_script
|
159
167
|
File.write master_script_path, script.code(tab_indent: Settings.tab_indent)
|
160
|
-
FileUtils.chmod
|
168
|
+
FileUtils.chmod '+x', master_script_path
|
161
169
|
quiet_say "!txtgrn!created!txtrst! #{master_script_path}"
|
162
170
|
end
|
163
171
|
|
164
172
|
def script
|
165
|
-
@script ||= Script::Wrapper.new
|
173
|
+
@script ||= Script::Wrapper.new command, args['--wrap']
|
166
174
|
end
|
167
175
|
|
168
176
|
def master_script_path
|
@@ -172,7 +180,6 @@ module Bashly
|
|
172
180
|
def command
|
173
181
|
@command ||= Script::Command.new config
|
174
182
|
end
|
175
|
-
|
176
183
|
end
|
177
184
|
end
|
178
185
|
end
|
data/lib/bashly/commands/init.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
module Bashly
|
2
2
|
module Commands
|
3
3
|
class Init < Base
|
4
|
-
summary
|
5
|
-
help
|
4
|
+
summary 'Initialize a new workspace'
|
5
|
+
help 'This command will create the source folder, and place a template configuration file in it.'
|
6
6
|
|
7
|
-
usage
|
8
|
-
usage
|
7
|
+
usage 'bashly init [--minimal]'
|
8
|
+
usage 'bashly init (-h|--help)'
|
9
9
|
|
10
|
-
option
|
10
|
+
option '-m --minimal', 'Use a minimal configuration file (without commands)'
|
11
11
|
|
12
|
-
environment
|
12
|
+
environment 'BASHLY_SOURCE_DIR', 'The path to use for creating the configuration file [default: src]'
|
13
13
|
|
14
14
|
def run
|
15
|
-
if Dir.exist?
|
15
|
+
if Dir.exist?(target_dir) && !Dir.empty?(target_dir)
|
16
16
|
raise InitError, "Directory !txtgrn!#{target_dir}!txtrst! already exists and is not empty"
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
FileUtils.mkdir_p target_dir
|
19
20
|
File.write "#{target_dir}/bashly.yml", yaml_content
|
20
21
|
say "!txtgrn!created!txtrst! #{target_dir}/bashly.yml"
|
21
|
-
say
|
22
|
+
say 'run !txtpur!bashly generate!txtrst! to create the bash script'
|
22
23
|
end
|
23
24
|
|
24
25
|
private
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Bashly
|
2
2
|
module Commands
|
3
3
|
class Preview < Base
|
4
|
-
help
|
4
|
+
help 'Generate the bash script to STDOUT'
|
5
5
|
|
6
|
-
usage
|
7
|
-
usage
|
6
|
+
usage 'bashly preview'
|
7
|
+
usage 'bashly preview (-h|--help)'
|
8
8
|
|
9
|
-
environment
|
9
|
+
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source files [default: src]'
|
10
10
|
|
11
11
|
def run
|
12
12
|
with_valid_config do
|
@@ -1,25 +1,26 @@
|
|
1
1
|
module Bashly
|
2
2
|
module Commands
|
3
3
|
class Validate < Base
|
4
|
-
help
|
4
|
+
help 'Scan the configuration file for errors'
|
5
5
|
|
6
|
-
usage
|
7
|
-
usage
|
6
|
+
usage 'bashly validate [--verbose]'
|
7
|
+
usage 'bashly validate (-h|--help)'
|
8
8
|
|
9
|
-
option
|
9
|
+
option '-v --verbose', 'Show the bashly configuration file prior to validating. ' \
|
10
|
+
'This is useful when using split config (import) since it will show the final compiled configuration.'
|
10
11
|
|
11
|
-
environment
|
12
|
+
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source files [default: src]'
|
12
13
|
|
13
14
|
def run
|
14
15
|
if args['--verbose']
|
15
16
|
lp config
|
16
|
-
puts
|
17
|
+
puts '---'
|
17
18
|
end
|
18
19
|
validate_config
|
19
20
|
show_deprecations
|
20
21
|
deprecations = config_validator.deprecations
|
21
22
|
if deprecations.empty?
|
22
|
-
say
|
23
|
+
say '!txtgrn!OK'
|
23
24
|
else
|
24
25
|
say "!txtred!WARNING!txtrst! Found #{deprecations.count} deprecations"
|
25
26
|
end
|
@@ -6,16 +6,14 @@ module Bashly
|
|
6
6
|
module Completions
|
7
7
|
module Flag
|
8
8
|
def completion_data(command_full_name)
|
9
|
-
result = {}
|
10
9
|
comps = allowed || completions
|
10
|
+
return {} unless comps
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
aliases.to_h do |name|
|
13
|
+
prefix = command_full_name
|
14
|
+
prefix = "#{prefix}*" unless prefix.end_with? '*'
|
15
|
+
["#{prefix}#{name}", comps]
|
16
16
|
end
|
17
|
-
|
18
|
-
result
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -23,13 +21,14 @@ module Bashly
|
|
23
21
|
def completion_data(with_version: true)
|
24
22
|
result = {}
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
completion_full_names.each do |name|
|
25
|
+
name = "#{name}*" if name.include? '*'
|
26
|
+
result[name] = completion_words with_version: with_version
|
28
27
|
flags.each do |flag|
|
29
28
|
result.merge! flag.completion_data(name)
|
30
29
|
end
|
31
30
|
end
|
32
|
-
|
31
|
+
|
33
32
|
commands.each do |command|
|
34
33
|
result.merge! command.completion_data(with_version: false)
|
35
34
|
end
|
@@ -42,13 +41,24 @@ module Bashly
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def completion_function(name = nil)
|
45
|
-
completion_generator.wrapper_function
|
44
|
+
completion_generator.wrapper_function name
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def completion_full_names
|
50
|
+
if parent_command
|
51
|
+
glue = parent_command.global_flags? ? '*' : ' '
|
52
|
+
parent_command.completion_full_names.product(aliases).map { |a| a.join glue }
|
53
|
+
else
|
54
|
+
aliases
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
58
|
private
|
49
59
|
|
50
60
|
def completion_generator
|
51
|
-
Completely::Completions.new
|
61
|
+
Completely::Completions.new completion_data
|
52
62
|
end
|
53
63
|
|
54
64
|
def completion_flag_names
|
@@ -63,14 +73,13 @@ module Bashly
|
|
63
73
|
trivial_flags = %w[--help -h]
|
64
74
|
trivial_flags += %w[--version -v] if with_version
|
65
75
|
all = (
|
66
|
-
command_aliases + trivial_flags +
|
76
|
+
command_aliases + trivial_flags +
|
67
77
|
completion_flag_names + completion_allowed_args
|
68
78
|
)
|
69
79
|
|
70
80
|
all += completions if completions
|
71
81
|
all.compact.uniq.sort
|
72
82
|
end
|
73
|
-
|
74
83
|
end
|
75
84
|
end
|
76
|
-
end
|
85
|
+
end
|
@@ -11,7 +11,7 @@ module Bashly
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def view_marker(id = nil)
|
14
|
-
id ||= ":#{caller_locations.first.path}"
|
14
|
+
id ||= ":#{caller_locations(1..1).first.path}"
|
15
15
|
"# #{id}" unless Settings.production?
|
16
16
|
end
|
17
17
|
|
@@ -23,7 +23,7 @@ module Bashly
|
|
23
23
|
content = if File.exist? path
|
24
24
|
File.read(path).remove_front_matter
|
25
25
|
elsif placeholder
|
26
|
-
|
26
|
+
'echo "error: cannot load file"'
|
27
27
|
else
|
28
28
|
''
|
29
29
|
end
|
@@ -38,15 +38,15 @@ module Bashly
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def self_views_path
|
41
|
-
@
|
41
|
+
@self_views_path ||= "#{base_views_path}/#{views_subfolder}"
|
42
42
|
end
|
43
43
|
|
44
44
|
def base_views_path
|
45
|
-
@base_views_path ||= File.expand_path
|
45
|
+
@base_views_path ||= File.expand_path '../views/', __dir__
|
46
46
|
end
|
47
47
|
|
48
48
|
def views_subfolder
|
49
49
|
@views_subfolder ||= self.class.name.split('::').last.to_underscore
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
52
|
+
end
|