bashly 1.0.1 → 1.0.2
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/lib/bashly/concerns/renderable.rb +18 -1
- data/lib/bashly/libraries/hooks/after.sh +7 -0
- data/lib/bashly/libraries/hooks/before.sh +8 -0
- data/lib/bashly/libraries/libraries.yml +8 -0
- data/lib/bashly/version.rb +1 -1
- data/lib/bashly/views/command/dependencies_filter.gtx +1 -1
- data/lib/bashly/views/command/initialize.gtx +1 -1
- data/lib/bashly/views/command/master_script.gtx +1 -0
- data/lib/bashly/views/command/run.gtx +13 -13
- data/lib/bashly/views/command/user_hooks.gtx +17 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67c0cd0da5f37edbad28313553ac30b878edae7d2255158d940af0deb8aa0a05
|
4
|
+
data.tar.gz: 6cf9bac796564e7730f3a55e6022d78a962506b418eb00cdecbe1111f3770ffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16eb355eb439bfc24457b184dd8255c091bb62dc1646c15e6d2842160f8848595de799cb453e54e43cdf5c2605906ed8f8c49ee21f5afda3999c9224b8d6fbc6
|
7
|
+
data.tar.gz: 889722479c576c8b30c3be1081911d0a7f61613664fc146fb4a2867b65d7199a5283464cc59eb40530e2c43f8270fbaa11e7f3a3d851cedc87a71515aef235b8
|
@@ -10,6 +10,7 @@ module Bashly
|
|
10
10
|
@strings ||= MessageStrings.new
|
11
11
|
end
|
12
12
|
|
13
|
+
# Outputs a comment that describes the view unless in production mode
|
13
14
|
def view_marker(id = nil)
|
14
15
|
id ||= ":#{caller_locations(1..1).first.path}"
|
15
16
|
"# #{id}" unless Settings.production?
|
@@ -18,7 +19,7 @@ module Bashly
|
|
18
19
|
# Reads a file from the userspace (Settings.source_dir) and returns
|
19
20
|
# its contents. If the file is not found, returns a string with a hint.
|
20
21
|
def load_user_file(file, placeholder: true)
|
21
|
-
path =
|
22
|
+
path = user_file_path file
|
22
23
|
|
23
24
|
content = if File.exist? path
|
24
25
|
File.read(path).remove_front_matter
|
@@ -31,6 +32,22 @@ module Bashly
|
|
31
32
|
Settings.production? ? content : "#{view_marker path}\n#{content}"
|
32
33
|
end
|
33
34
|
|
35
|
+
# Returns a path to a file in the user's source_dir. The file argument
|
36
|
+
# should either be without exteneion, or with the user's configured
|
37
|
+
# partials_extension.
|
38
|
+
def user_file_path(file)
|
39
|
+
path = "#{Settings.source_dir}/#{file}"
|
40
|
+
ext = ".#{Settings.partials_extension}"
|
41
|
+
return path if path.end_with? ext
|
42
|
+
|
43
|
+
"#{path}#{ext}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns true if the user's source file exists
|
47
|
+
def user_file_exist?(file)
|
48
|
+
File.exist? user_file_path(file)
|
49
|
+
end
|
50
|
+
|
34
51
|
private
|
35
52
|
|
36
53
|
def view_path(view)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
## before hook
|
2
|
+
##
|
3
|
+
## Any code here will be placed inside a `before_hook()` function and called
|
4
|
+
## before running any command (but after processing its arguments).
|
5
|
+
##
|
6
|
+
## You can safely delete this file if you do not need it.
|
7
|
+
echo "==[ Before Hook Called ]=="
|
8
|
+
inspect_args
|
@@ -29,6 +29,14 @@ help:
|
|
29
29
|
help: Add a help command, in addition to the standard --help flag.
|
30
30
|
handler: Bashly::Libraries::Help
|
31
31
|
|
32
|
+
hooks:
|
33
|
+
help: Add placeholders for before/after hooks which are executed before/after any command.
|
34
|
+
files:
|
35
|
+
- source: "hooks/before.sh"
|
36
|
+
target: "%{user_source_dir}/before.%{user_ext}"
|
37
|
+
- source: "hooks/after.sh"
|
38
|
+
target: "%{user_source_dir}/after.%{user_ext}"
|
39
|
+
|
32
40
|
lib:
|
33
41
|
help: |-
|
34
42
|
Create the lib directory for any additional user scripts.
|
data/lib/bashly/version.rb
CHANGED
@@ -7,26 +7,26 @@
|
|
7
7
|
> declare -a input=()
|
8
8
|
> normalize_input "$@"
|
9
9
|
> parse_requirements "${input[@]}"
|
10
|
+
if user_file_exist?('before')
|
11
|
+
> before_hook
|
12
|
+
end
|
10
13
|
>
|
11
14
|
> case "$action" in
|
12
15
|
|
13
16
|
deep_commands.each do |command|
|
14
|
-
> "{{ command.action_name }}")
|
15
|
-
> if [[ ${args['--help']:-} ]]; then
|
16
|
-
> long_usage=yes
|
17
|
-
> {{ command.function_name }}_usage
|
18
|
-
> else
|
19
|
-
> {{ command.function_name }}_command
|
20
|
-
> fi
|
21
|
-
> ;;
|
22
|
-
>
|
17
|
+
> "{{ command.action_name }}") {{ command.function_name }}_command ;;
|
23
18
|
end
|
24
19
|
|
25
20
|
if commands.empty?
|
26
|
-
> "root")
|
27
|
-
> root_command
|
28
|
-
> ;;
|
21
|
+
> "root") root_command ;;
|
29
22
|
end
|
30
|
-
>
|
31
23
|
> esac
|
24
|
+
|
25
|
+
if user_file_exist?('after')
|
26
|
+
>
|
27
|
+
> after_hook
|
28
|
+
end
|
29
|
+
|
32
30
|
> }
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
if user_file_exist?('before') || user_file_exist?('after')
|
2
|
+
= view_marker
|
3
|
+
end
|
4
|
+
|
5
|
+
if user_file_exist?('before')
|
6
|
+
> before_hook() {
|
7
|
+
= load_user_file("before").indent 2
|
8
|
+
> }
|
9
|
+
>
|
10
|
+
end
|
11
|
+
|
12
|
+
if user_file_exist?('after')
|
13
|
+
> after_hook() {
|
14
|
+
= load_user_file("after").indent 2
|
15
|
+
> }
|
16
|
+
>
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bashly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -155,6 +155,8 @@ files:
|
|
155
155
|
- lib/bashly/libraries/config/config.sh
|
156
156
|
- lib/bashly/libraries/help/help.rb
|
157
157
|
- lib/bashly/libraries/help/help_command.sh
|
158
|
+
- lib/bashly/libraries/hooks/after.sh
|
159
|
+
- lib/bashly/libraries/hooks/before.sh
|
158
160
|
- lib/bashly/libraries/lib/sample_function.sh
|
159
161
|
- lib/bashly/libraries/libraries.yml
|
160
162
|
- lib/bashly/libraries/settings/settings.yml
|
@@ -222,6 +224,7 @@ files:
|
|
222
224
|
- lib/bashly/views/command/usage_fixed_flags.gtx
|
223
225
|
- lib/bashly/views/command/usage_flags.gtx
|
224
226
|
- lib/bashly/views/command/user_filter.gtx
|
227
|
+
- lib/bashly/views/command/user_hooks.gtx
|
225
228
|
- lib/bashly/views/command/user_lib.gtx
|
226
229
|
- lib/bashly/views/command/version_command.gtx
|
227
230
|
- lib/bashly/views/command/whitelist_filter.gtx
|
@@ -259,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
262
|
- !ruby/object:Gem::Version
|
260
263
|
version: '0'
|
261
264
|
requirements: []
|
262
|
-
rubygems_version: 3.4.
|
265
|
+
rubygems_version: 3.4.8
|
263
266
|
signing_key:
|
264
267
|
specification_version: 4
|
265
268
|
summary: Bash Command Line Tool Generator
|