bash_help 0.0.5 → 0.0.6
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/general_helpers.rb +18 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5ea3c23f7cfe859565d88a1b5e1cc6ea5ad45b0ba88113e0674bd68a9a7480
|
4
|
+
data.tar.gz: 01146b54892d107d977fe8f4b88197242c6d2c644e68b258afb6f77594fa3696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d914a3d9ba07446fe3192cea18f24c0e3859630c94af472f1267c26bcd56673a1fdd5995db5a8735f2a1374fe97e5179aa19e517f813f0a00fc6abf72cace132
|
7
|
+
data.tar.gz: 0d86f7249d67720f2893f4a671c93bfa50d24396fe26a9676ed9d92abfd7676287047b259a96037ddae8cf3da98a1d86d111e1fcc5a548f13e3c82a91e4262b1
|
data/lib/general_helpers.rb
CHANGED
@@ -35,9 +35,25 @@ def print_method_sig(method_name)
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# function usage string, with a custom string param that formats it for you.
|
38
|
-
def usage(method_name, custom_usage_string)
|
38
|
+
def usage(method_name, custom_usage_string, should_exit = true)
|
39
39
|
puts "Usage for #{method_name}:"
|
40
40
|
print_method_sig(method_name)
|
41
41
|
puts custom_usage_string
|
42
|
-
|
42
|
+
if should_exit
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# require every file in a directory.
|
48
|
+
def require_dir(directory_path)
|
49
|
+
# Get an array of all files in the directory
|
50
|
+
script_files = Dir.glob(File.join(directory_path, '*.rb'))
|
51
|
+
|
52
|
+
# Iterate over each script file
|
53
|
+
script_files.each do |script_file|
|
54
|
+
# Require or load the script file
|
55
|
+
require script_file
|
56
|
+
# Or if you want to load instead of requiring:
|
57
|
+
# load script_file
|
58
|
+
end
|
43
59
|
end
|