@@ -8,6 +8,7 @@ class Add < Base
88 usage "bashly add config [--force]"
99 usage "bashly add colors [--force]"
1010 usage "bashly add yaml [--force]"
11+ usage "bashly add validations [--force]"
1112 usage "bashly add comp FORMAT [OUTPUT]"
1213 usage "bashly add (-h|--help)"
1314
@@ -21,6 +22,7 @@ class Add < Base
2122 command "config" , "Add standard functions for handling INI files to the lib directory."
2223 command "colors" , "Add standard functions for printing colorful and formatted text to the lib directory."
2324 command "yaml" , "Add standard functions for reading YAML files to the lib directory."
25+ command "validations" , "Add argument validation functions to the lib directory."
2426 command "comp" , "Generate a bash completions script or function."
2527
2628 example "bashly add strings --force"
@@ -34,19 +36,23 @@ def strings_command
3436 end
3537
3638 def lib_command
37- safe_copy_lib "sample_function.sh"
39+ safe_copy_file "sample_function.sh"
3840 end
3941
4042 def config_command
41- safe_copy_lib "config.sh"
43+ safe_copy_file "config.sh"
4244 end
4345
4446 def colors_command
45- safe_copy_lib "colors.sh"
47+ safe_copy_file "colors.sh"
4648 end
4749
4850 def yaml_command
49- safe_copy_lib "yaml.sh"
51+ safe_copy_file "yaml.sh"
52+ end
53+
54+ def validations_command
55+ safe_copy_dir "validations"
5056 end
5157
5258 def comp_command
@@ -68,8 +74,14 @@ def comp_command
6874
6975 private
7076
71- def safe_copy_lib ( libfile )
72- safe_copy asset ( "templates/lib/#{ libfile } " ) , "#{ Settings . source_dir } /lib/#{ libfile } "
77+ def safe_copy_dir ( dir )
78+ Dir [ asset ( "templates/lib/#{ dir } /*.sh" ) ] . each do |file |
79+ safe_copy_file "#{ dir } /#{ File . basename file } "
80+ end
81+ end
82+
83+ def safe_copy_file ( file )
84+ safe_copy asset ( "templates/lib/#{ file } " ) , "#{ Settings . source_dir } /lib/#{ file } "
7385 end
7486
7587 def safe_copy ( source , target )
0 commit comments