bashly 0.9.4 → 1.0.0.rc1
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/README.md +1 -1
- data/bin/bashly +1 -1
- data/lib/bashly/cli.rb +1 -1
- data/lib/bashly/commands/add.rb +42 -90
- data/lib/bashly/commands/base.rb +1 -9
- data/lib/bashly/commands/doc.rb +7 -7
- data/lib/bashly/commands/generate.rb +28 -33
- data/lib/bashly/commands/init.rb +3 -5
- data/lib/bashly/commands/preview.rb +0 -2
- data/lib/bashly/commands/validate.rb +1 -9
- data/lib/bashly/concerns/validation_helpers.rb +0 -8
- data/lib/bashly/config_validator.rb +1 -9
- data/lib/bashly/docs/command.yml +1 -1
- data/lib/bashly/docs/env.yml +1 -1
- data/lib/bashly/docs/flag.yml +11 -1
- data/lib/bashly/libraries/base.rb +1 -1
- data/lib/bashly/{templates/lib → libraries/colors}/colors.sh +0 -0
- data/lib/bashly/libraries/{completions_function.rb → completions/completions_function.rb} +2 -2
- data/lib/bashly/libraries/{completions_script.rb → completions/completions_script.rb} +1 -1
- data/lib/bashly/libraries/{completions_yaml.rb → completions/completions_yaml.rb} +1 -1
- data/lib/bashly/{templates/lib → libraries/config}/config.sh +0 -0
- data/lib/bashly/libraries/{help.rb → help/help.rb} +7 -7
- data/lib/bashly/{templates → libraries}/help/help_command.sh +0 -0
- data/lib/bashly/{templates → libraries}/lib/sample_function.sh +0 -0
- data/lib/bashly/libraries/libraries.yml +85 -0
- data/lib/bashly/{templates → libraries/settings}/settings.yml +7 -1
- data/lib/bashly/{templates → libraries/strings}/strings.yml +0 -0
- data/lib/bashly/{templates → libraries}/test/approvals.bash +0 -0
- data/lib/bashly/{templates → libraries}/test/approve +0 -0
- data/lib/bashly/{templates/lib → libraries}/validations/validate_dir_exists.sh +0 -0
- data/lib/bashly/{templates/lib → libraries}/validations/validate_file_exists.sh +0 -0
- data/lib/bashly/{templates/lib → libraries}/validations/validate_integer.sh +0 -0
- data/lib/bashly/{templates/lib → libraries}/validations/validate_not_empty.sh +0 -0
- data/lib/bashly/{templates/lib → libraries/yaml}/yaml.sh +0 -0
- data/lib/bashly/library.rb +14 -25
- data/lib/bashly/library_source.rb +84 -0
- data/lib/bashly/message_strings.rb +1 -1
- data/lib/bashly/refinements/compose_refinements.rb +2 -2
- data/lib/bashly/script/command.rb +10 -4
- data/lib/bashly/script/flag.rb +1 -1
- data/lib/bashly/settings.rb +21 -4
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/long_usage.gtx +2 -2
- data/lib/bashly/views/command/usage_environment_variables.gtx +1 -1
- data/lib/bashly/views/command/usage_flags.gtx +1 -1
- metadata +46 -40
- data/lib/bashly/deprecation.rb +0 -27
- data/lib/bashly/libraries.yml +0 -60
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b23af9b1533c906c685ef6f62620bb32b55fb45599e354e85548e800d7ecf832
|
|
4
|
+
data.tar.gz: e65e8f10fefd0b2945c9c31459ee427b9688a5d8565880ddbce3021d2b8b1c6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c82c7e9a804e2d95d1a4179aaf96948c7f9e8150f64ace8d8b87b990a5157f22def814289f2aebb82869fafdd38fb03fc3aeec4fc752ff836c37efe0e53e389
|
|
7
|
+
data.tar.gz: b82bc5d7be814046b42fc959238f3a455d3f1f9c17fa0d2a5e1a3cd2e516db64db33ed9d62afcdfef8368f33a7c3b5a4b65ac58bd9d3aa308aacc1130e9983de
|
data/README.md
CHANGED
data/bin/bashly
CHANGED
data/lib/bashly/cli.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Bashly
|
|
|
7
7
|
def self.runner
|
|
8
8
|
runner = MisterBin::Runner.new version: Bashly::VERSION,
|
|
9
9
|
header: 'Bashly - Bash CLI Generator',
|
|
10
|
-
footer: "Help:
|
|
10
|
+
footer: "Help: m`bashly COMMAND --help`\nDocs: bu`https://bashly.dannyb.co`"
|
|
11
11
|
|
|
12
12
|
runner.route 'init', to: Commands::Init
|
|
13
13
|
runner.route 'preview', to: Commands::Preview
|
data/lib/bashly/commands/add.rb
CHANGED
|
@@ -3,120 +3,72 @@ module Bashly
|
|
|
3
3
|
class Add < Base
|
|
4
4
|
help 'Add extra features and customization to your script'
|
|
5
5
|
|
|
6
|
-
usage 'bashly add
|
|
7
|
-
usage 'bashly add
|
|
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]'
|
|
6
|
+
usage 'bashly add [--source NAME] LIBRARY [ARGS...] [--force]'
|
|
7
|
+
usage 'bashly add [--source NAME] --list'
|
|
16
8
|
usage 'bashly add (-h|--help)'
|
|
17
9
|
|
|
18
|
-
option '-
|
|
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
|
|
10
|
+
option '-s --source NAME', <<~USAGE
|
|
11
|
+
Specify a different libraries source. NAME can be:
|
|
26
12
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
* Path to a local libraries directory
|
|
14
|
+
* GitHub (HTTPS) repository: github:user/repo[//path@ref]
|
|
15
|
+
* GitHub (SSH) repository: github-ssh:user/repo[//path@ref]
|
|
16
|
+
* Remote git repository: git:repo-url.git[//path@ref]
|
|
31
17
|
USAGE
|
|
32
|
-
|
|
33
|
-
|
|
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]'
|
|
18
|
+
option '-f --force', 'Overwrite existing files'
|
|
19
|
+
option '-l --list', 'Show available libraries'
|
|
59
20
|
|
|
60
21
|
attr_reader :skip_src_check
|
|
61
22
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def comp_command
|
|
67
|
-
format = args['FORMAT']
|
|
68
|
-
output = args['OUTPUT']
|
|
23
|
+
def run
|
|
24
|
+
say "Performing git operations, this may take a while...\n" if lib_source.git?
|
|
69
25
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
else raise Error, "Unrecognized format: #{format}"
|
|
26
|
+
if args['--list']
|
|
27
|
+
show_list
|
|
28
|
+
else
|
|
29
|
+
add_lib args['LIBRARY']
|
|
75
30
|
end
|
|
76
|
-
end
|
|
77
31
|
|
|
78
|
-
|
|
79
|
-
add_lib 'config'
|
|
32
|
+
lib_source.cleanup if lib_source.git?
|
|
80
33
|
end
|
|
81
34
|
|
|
82
|
-
|
|
83
|
-
add_lib 'lib'
|
|
84
|
-
end
|
|
35
|
+
private
|
|
85
36
|
|
|
86
|
-
def
|
|
87
|
-
|
|
88
|
-
add_lib 'settings'
|
|
37
|
+
def source
|
|
38
|
+
args['--source']
|
|
89
39
|
end
|
|
90
40
|
|
|
91
|
-
def
|
|
92
|
-
|
|
41
|
+
def lib_source
|
|
42
|
+
@lib_source ||= Bashly::LibrarySource.new source
|
|
93
43
|
end
|
|
94
44
|
|
|
95
|
-
def
|
|
96
|
-
|
|
45
|
+
def show_list
|
|
46
|
+
lib_source.config.each do |key, config|
|
|
47
|
+
usage = key
|
|
48
|
+
usage += " #{config['usage']}" if config['usage']
|
|
49
|
+
say "g`#{usage}`"
|
|
50
|
+
say word_wrap(" #{config['help']}")
|
|
51
|
+
say ''
|
|
52
|
+
end
|
|
97
53
|
end
|
|
98
54
|
|
|
99
|
-
def
|
|
100
|
-
|
|
101
|
-
|
|
55
|
+
def add_lib(name)
|
|
56
|
+
library = lib_source.libraries[name.to_sym]
|
|
57
|
+
raise "Unknown library: g`#{name}`\nRun m`bashly add --list` to see available libraries" unless library
|
|
102
58
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
end
|
|
59
|
+
library.args = args['ARGS']
|
|
60
|
+
@skip_src_check = lib_source.config.dig name, 'skip_src_check'
|
|
106
61
|
|
|
107
|
-
|
|
108
|
-
add_lib 'yaml'
|
|
62
|
+
add_library_files library
|
|
109
63
|
end
|
|
110
64
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def add_lib(name, *args)
|
|
114
|
-
library = Bashly::Library.new name, *args
|
|
65
|
+
def add_library_files(library)
|
|
115
66
|
files_created = 0
|
|
116
67
|
library.files.each do |file|
|
|
117
68
|
created = safe_write file[:path], file[:content]
|
|
118
69
|
files_created += 1 if created
|
|
119
70
|
end
|
|
71
|
+
|
|
120
72
|
message = library.post_install_message
|
|
121
73
|
say "\n#{message}" if message && files_created.positive?
|
|
122
74
|
end
|
|
@@ -124,18 +76,18 @@ module Bashly
|
|
|
124
76
|
def safe_write(path, content)
|
|
125
77
|
if !skip_src_check && !Dir.exist?(Settings.source_dir)
|
|
126
78
|
raise InitError, <<~ERROR
|
|
127
|
-
Directory
|
|
128
|
-
Run
|
|
79
|
+
Directory g`#{Settings.source_dir}` does not exist
|
|
80
|
+
Run m`bashly init` first
|
|
129
81
|
ERROR
|
|
130
82
|
end
|
|
131
83
|
|
|
132
84
|
if File.exist?(path) && !args['--force']
|
|
133
|
-
say "
|
|
85
|
+
say "b`skipped` #{path} (exists)"
|
|
134
86
|
false
|
|
135
87
|
|
|
136
88
|
else
|
|
137
89
|
File.deep_write path, content
|
|
138
|
-
say "
|
|
90
|
+
say "g`created` #{path}"
|
|
139
91
|
true
|
|
140
92
|
|
|
141
93
|
end
|
data/lib/bashly/commands/base.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Bashly
|
|
|
7
7
|
include AssetHelper
|
|
8
8
|
|
|
9
9
|
def config
|
|
10
|
-
@config ||= Config.new
|
|
10
|
+
@config ||= Config.new Settings.config_path
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def config_validator
|
|
@@ -21,14 +21,6 @@ module Bashly
|
|
|
21
21
|
def with_valid_config
|
|
22
22
|
validate_config
|
|
23
23
|
yield
|
|
24
|
-
show_deprecations
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def show_deprecations
|
|
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"
|
|
32
24
|
end
|
|
33
25
|
end
|
|
34
26
|
end
|
data/lib/bashly/commands/doc.rb
CHANGED
|
@@ -35,27 +35,27 @@ module Bashly
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def show_key(key)
|
|
38
|
-
say "
|
|
38
|
+
say "g`#{key}`"
|
|
39
39
|
say ''
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def show_url(url)
|
|
43
|
-
say " See
|
|
43
|
+
say " See bu`#{url}`"
|
|
44
44
|
say ''
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def show_example(example)
|
|
48
48
|
example = word_wrap " #{example}"
|
|
49
|
-
example.gsub!(/^(\s*- )?(\s*\w+):/, '\
|
|
50
|
-
example.gsub!(/^(\s*- )/, '
|
|
51
|
-
example.gsub!(/^(\s*#.+)/, '
|
|
49
|
+
example.gsub!(/^(\s*- )?(\s*\w+):/, '\1b`\2`:')
|
|
50
|
+
example.gsub!(/^(\s*- )/, 'y`\1`')
|
|
51
|
+
example.gsub!(/^(\s*#.+)/, 'm`\1`')
|
|
52
52
|
say example
|
|
53
53
|
say ''
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def show_help(help)
|
|
57
57
|
help = word_wrap " #{help}"
|
|
58
|
-
help.gsub!(/`([^`]+)`/, '
|
|
58
|
+
help.gsub!(/`([^`]+)`/, 'g`\1`')
|
|
59
59
|
say help
|
|
60
60
|
say ''
|
|
61
61
|
end
|
|
@@ -63,7 +63,7 @@ module Bashly
|
|
|
63
63
|
def data
|
|
64
64
|
return raw_data unless args['SEARCH']
|
|
65
65
|
|
|
66
|
-
result = raw_data.select { |k, _v| k
|
|
66
|
+
result = raw_data.select { |k, _v| k == args['SEARCH'] }
|
|
67
67
|
return result if result.any?
|
|
68
68
|
|
|
69
69
|
result = raw_data.select { |k, _v| k.include? args['SEARCH'] }
|
|
@@ -13,26 +13,11 @@ module Bashly
|
|
|
13
13
|
option '-u --upgrade', 'Upgrade all added library functions'
|
|
14
14
|
option '-w --watch', 'Watch the source directory for changes and regenerate on change'
|
|
15
15
|
option '-r --wrap FUNCTION', 'Wrap the entire script in a function so it can also be sourced'
|
|
16
|
-
option '-e --env ENV',
|
|
16
|
+
option '-e --env ENV', <<~HELP
|
|
17
|
+
Force the generation environment:
|
|
17
18
|
|
|
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
|
|
31
|
-
Set to 'production' or 'development':
|
|
32
19
|
- production generate a smaller script, without file markers
|
|
33
20
|
- development generate with file markers
|
|
34
|
-
|
|
35
|
-
Can be overridden with --env [default: development]
|
|
36
21
|
HELP
|
|
37
22
|
|
|
38
23
|
example 'bashly generate --force'
|
|
@@ -52,25 +37,25 @@ module Bashly
|
|
|
52
37
|
private
|
|
53
38
|
|
|
54
39
|
def watch
|
|
55
|
-
quiet_say "
|
|
40
|
+
quiet_say "g`watching` #{Settings.source_dir}\n"
|
|
56
41
|
|
|
57
42
|
Filewatcher.new([Settings.source_dir]).watch do
|
|
58
43
|
reset
|
|
59
44
|
generate
|
|
60
45
|
|
|
61
46
|
rescue Bashly::ConfigurationError => e
|
|
62
|
-
say! "
|
|
47
|
+
say! "rib` #{e.class} `\n#{e.message}"
|
|
63
48
|
|
|
64
49
|
ensure
|
|
65
|
-
quiet_say "
|
|
50
|
+
quiet_say "g`waiting`\n"
|
|
66
51
|
end
|
|
67
52
|
end
|
|
68
53
|
|
|
69
54
|
def generate
|
|
70
55
|
with_valid_config do
|
|
71
|
-
quiet_say 'creating
|
|
56
|
+
quiet_say 'creating g`production` version' if Settings.production?
|
|
72
57
|
generate_all_files
|
|
73
|
-
quiet_say "run
|
|
58
|
+
quiet_say "run m`#{master_script_path} --help` to test your bash script" unless watching
|
|
74
59
|
end
|
|
75
60
|
end
|
|
76
61
|
|
|
@@ -97,6 +82,7 @@ module Bashly
|
|
|
97
82
|
next unless content =~ /\[@bashly-upgrade (.+)\]/
|
|
98
83
|
|
|
99
84
|
args = $1.split
|
|
85
|
+
|
|
100
86
|
library_name = args.shift
|
|
101
87
|
upgrade file, library_name, *args
|
|
102
88
|
end
|
|
@@ -107,28 +93,37 @@ module Bashly
|
|
|
107
93
|
end
|
|
108
94
|
|
|
109
95
|
def upgrade(existing_file, library_name, *args)
|
|
110
|
-
if
|
|
111
|
-
|
|
96
|
+
if library_name.include? ';'
|
|
97
|
+
source_name, library_name = library_name.split(';')
|
|
98
|
+
source = Bashly::LibrarySource.new source_name
|
|
99
|
+
else
|
|
100
|
+
source = Bashly::LibrarySource.new
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
library = source.libraries[library_name.to_sym]
|
|
104
|
+
|
|
105
|
+
if library
|
|
106
|
+
library.args = args
|
|
107
|
+
upgrade! existing_file, library
|
|
112
108
|
else
|
|
113
|
-
quiet_say "
|
|
109
|
+
quiet_say "r`warning` not upgrading c`#{existing_file}`, " \
|
|
114
110
|
"unknown library '#{library_name}'"
|
|
115
111
|
end
|
|
116
112
|
end
|
|
117
113
|
|
|
118
|
-
def upgrade!(existing_file,
|
|
119
|
-
library = Bashly::Library.new library_name, *args
|
|
114
|
+
def upgrade!(existing_file, library)
|
|
120
115
|
file = library.find_file existing_file
|
|
121
116
|
|
|
122
117
|
if file
|
|
123
118
|
File.deep_write file[:path], file[:content]
|
|
124
|
-
quiet_say "
|
|
119
|
+
quiet_say "c`updated` #{file[:path]}"
|
|
125
120
|
else
|
|
126
|
-
quiet_say "
|
|
121
|
+
quiet_say "r`warning` not upgrading c`#{existing_file}`, path mismatch"
|
|
127
122
|
end
|
|
128
123
|
end
|
|
129
124
|
|
|
130
125
|
def create_user_files
|
|
131
|
-
quiet_say "creating user files in
|
|
126
|
+
quiet_say "creating user files in g`#{Settings.source_dir}`"
|
|
132
127
|
|
|
133
128
|
create_file "#{Settings.source_dir}/initialize.#{Settings.partials_extension}",
|
|
134
129
|
command.render(:default_initialize_script)
|
|
@@ -156,17 +151,17 @@ module Bashly
|
|
|
156
151
|
|
|
157
152
|
def create_file(file, content)
|
|
158
153
|
if File.exist?(file) && !args['--force']
|
|
159
|
-
quiet_say "
|
|
154
|
+
quiet_say "b`skipped` #{file} (exists)"
|
|
160
155
|
else
|
|
161
156
|
File.deep_write file, content
|
|
162
|
-
quiet_say "
|
|
157
|
+
quiet_say "g`created` #{file}"
|
|
163
158
|
end
|
|
164
159
|
end
|
|
165
160
|
|
|
166
161
|
def create_master_script
|
|
167
162
|
File.write master_script_path, script.code(tab_indent: Settings.tab_indent)
|
|
168
163
|
FileUtils.chmod '+x', master_script_path
|
|
169
|
-
quiet_say "
|
|
164
|
+
quiet_say "g`created` #{master_script_path}"
|
|
170
165
|
end
|
|
171
166
|
|
|
172
167
|
def script
|
data/lib/bashly/commands/init.rb
CHANGED
|
@@ -9,17 +9,15 @@ module Bashly
|
|
|
9
9
|
|
|
10
10
|
option '-m --minimal', 'Use a minimal configuration file (without commands)'
|
|
11
11
|
|
|
12
|
-
environment 'BASHLY_SOURCE_DIR', 'The path to use for creating the configuration file [default: src]'
|
|
13
|
-
|
|
14
12
|
def run
|
|
15
13
|
if Dir.exist?(target_dir) && !Dir.empty?(target_dir)
|
|
16
|
-
raise InitError, "Directory
|
|
14
|
+
raise InitError, "Directory g`#{target_dir}` already exists and is not empty"
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
FileUtils.mkdir_p target_dir
|
|
20
18
|
File.write "#{target_dir}/bashly.yml", yaml_content
|
|
21
|
-
say "
|
|
22
|
-
say 'run
|
|
19
|
+
say "g`created` #{target_dir}/bashly.yml"
|
|
20
|
+
say 'run m`bashly generate` to create the bash script'
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
private
|
|
@@ -6,8 +6,6 @@ module Bashly
|
|
|
6
6
|
usage 'bashly preview'
|
|
7
7
|
usage 'bashly preview (-h|--help)'
|
|
8
8
|
|
|
9
|
-
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source files [default: src]'
|
|
10
|
-
|
|
11
9
|
def run
|
|
12
10
|
with_valid_config do
|
|
13
11
|
command = Script::Command.new config
|
|
@@ -11,21 +11,13 @@ module Bashly
|
|
|
11
11
|
option '-v --verbose', 'Show the bashly configuration file prior to validating. ' \
|
|
12
12
|
'This is useful when using split config (import) since it will show the final compiled configuration.'
|
|
13
13
|
|
|
14
|
-
environment 'BASHLY_SOURCE_DIR', 'The path containing the bashly configuration and source files [default: src]'
|
|
15
|
-
|
|
16
14
|
def run
|
|
17
15
|
if args['--verbose']
|
|
18
16
|
lp config
|
|
19
17
|
puts '---'
|
|
20
18
|
end
|
|
21
19
|
validate_config
|
|
22
|
-
|
|
23
|
-
deprecations = config_validator.deprecations
|
|
24
|
-
if deprecations.empty?
|
|
25
|
-
say '!txtgrn!OK'
|
|
26
|
-
else
|
|
27
|
-
say "!txtred!WARNING!txtrst! Found #{deprecations.count} deprecations"
|
|
28
|
-
end
|
|
20
|
+
say 'g`OK`'
|
|
29
21
|
end
|
|
30
22
|
end
|
|
31
23
|
end
|
|
@@ -2,10 +2,6 @@ module Bashly
|
|
|
2
2
|
# This is a `ConfigValidator` concern responsible for providing basic
|
|
3
3
|
# assertion methods.
|
|
4
4
|
module ValidationHelpers
|
|
5
|
-
def deprecations
|
|
6
|
-
@deprecations ||= []
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
protected
|
|
10
6
|
|
|
11
7
|
def assert(valid, message)
|
|
@@ -16,10 +12,6 @@ module Bashly
|
|
|
16
12
|
assert !invalid, message
|
|
17
13
|
end
|
|
18
14
|
|
|
19
|
-
def deprecate(key, **options)
|
|
20
|
-
deprecations.push Deprecation.new(key, **options)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
15
|
def assert_string(key, value)
|
|
24
16
|
assert value.is_a?(String), "#{key} must be a string"
|
|
25
17
|
end
|
|
@@ -99,6 +99,7 @@ module Bashly
|
|
|
99
99
|
assert_optional_string "#{key}.default", value['default']
|
|
100
100
|
assert_optional_string "#{key}.validate", value['validate']
|
|
101
101
|
|
|
102
|
+
assert_boolean "#{key}.private", value['private']
|
|
102
103
|
assert_boolean "#{key}.repeatable", value['repeatable']
|
|
103
104
|
assert_boolean "#{key}.required", value['required']
|
|
104
105
|
assert_array "#{key}.allowed", value['allowed'], of: :string
|
|
@@ -131,10 +132,6 @@ module Bashly
|
|
|
131
132
|
assert_optional_string "#{key}.default", value['default']
|
|
132
133
|
assert_boolean "#{key}.required", value['required']
|
|
133
134
|
assert_boolean "#{key}.private", value['private']
|
|
134
|
-
|
|
135
|
-
if value['private']
|
|
136
|
-
assert value['default'], "#{key}.private makes no sense without default"
|
|
137
|
-
end
|
|
138
135
|
end
|
|
139
136
|
|
|
140
137
|
def assert_command(key, value)
|
|
@@ -196,11 +193,6 @@ module Bashly
|
|
|
196
193
|
refute value['version'], "#{key}.version makes no sense"
|
|
197
194
|
refute value['extensible'], "#{key}.extensible makes no sense"
|
|
198
195
|
end
|
|
199
|
-
|
|
200
|
-
# DEPRECATION 0.8.0
|
|
201
|
-
if value['short']
|
|
202
|
-
deprecate "#{key}.short", replacement: 'alias', reference: 'https://github.com/DannyBen/bashly/pull/220'
|
|
203
|
-
end
|
|
204
196
|
end
|
|
205
197
|
end
|
|
206
198
|
end
|
data/lib/bashly/docs/command.yml
CHANGED
|
@@ -75,7 +75,7 @@ command.commands:
|
|
|
75
75
|
help: Register a local repository
|
|
76
76
|
|
|
77
77
|
command.completions:
|
|
78
|
-
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add
|
|
78
|
+
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add completions`.
|
|
79
79
|
url: https://bashly.dannyb.co/configuration/command/#completions
|
|
80
80
|
example: |-
|
|
81
81
|
commands:
|
data/lib/bashly/docs/env.yml
CHANGED
|
@@ -36,7 +36,7 @@ environment_variable.name:
|
|
|
36
36
|
help: Your API key
|
|
37
37
|
|
|
38
38
|
environment_variable.private:
|
|
39
|
-
help: Specify that this environment variable should not be advertised in the usage text.
|
|
39
|
+
help: Specify that this environment variable should not be advertised in the usage text.
|
|
40
40
|
url: https://bashly.dannyb.co/configuration/environment-variable/#private
|
|
41
41
|
example: |-
|
|
42
42
|
environment_variables:
|
data/lib/bashly/docs/flag.yml
CHANGED
|
@@ -46,7 +46,7 @@ flag.arg:
|
|
|
46
46
|
help: Clone using SSH
|
|
47
47
|
|
|
48
48
|
flag.completions:
|
|
49
|
-
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add
|
|
49
|
+
help: Specify a list of additional completion suggestions when used in conjunction with `bashly add completions`. Must be accompanied by `arg`.
|
|
50
50
|
url: https://bashly.dannyb.co/configuration/flag/#completions
|
|
51
51
|
example: |-
|
|
52
52
|
flags:
|
|
@@ -112,6 +112,16 @@ flag.long:
|
|
|
112
112
|
short: -s
|
|
113
113
|
help: Clone using SSH
|
|
114
114
|
|
|
115
|
+
flag.private:
|
|
116
|
+
help: Specify that this flag should not be displayed in the help text.
|
|
117
|
+
url: https://bashly.dannyb.co/configuration/flag/#private
|
|
118
|
+
example: |-
|
|
119
|
+
flags:
|
|
120
|
+
- long: --legacy
|
|
121
|
+
short: -l
|
|
122
|
+
help: Run using the legacy mode
|
|
123
|
+
private: true
|
|
124
|
+
|
|
115
125
|
flag.repeatable:
|
|
116
126
|
help: |-
|
|
117
127
|
Specify that this flag can be provided multiple times. When used on a flag with an argument, it will be received as a space-delimited string, which needs to be converted to an array with:
|
|
File without changes
|
|
@@ -12,11 +12,11 @@ module Bashly
|
|
|
12
12
|
|
|
13
13
|
def post_install_message
|
|
14
14
|
<<~MESSAGE
|
|
15
|
-
In order to enable completions in your script, create a command or a flag (for example:
|
|
15
|
+
In order to enable completions in your script, create a command or a flag (for example: g`#{command.name} completions` or g`#{command.name} --completions`) that calls the g`#{function_name}` function.
|
|
16
16
|
|
|
17
17
|
Your users can then run something like this to enable completions:
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
m`$ eval "$(#{command.name} completions)"`
|
|
20
20
|
MESSAGE
|
|
21
21
|
end
|
|
22
22
|
|
|
File without changes
|