@@ -32,63 +32,52 @@ class Add < Base
3232 environment "BASHLY_SOURCE_DIR" , "The path containing the bashly configuration and source files [default: src]"
3333
3434 def strings_command
35- add_lib Library :: Strings . new
35+ add_lib 'strings'
3636 end
3737
3838 def lib_command
39- add_lib Library :: Sample . new
39+ add_lib 'lib'
4040 end
4141
4242 def config_command
43- add_lib Library :: Config . new
43+ add_lib 'config'
4444 end
4545
4646 def colors_command
47- add_lib Library :: Colors . new
47+ add_lib 'colors'
4848 end
4949
5050 def yaml_command
51- add_lib Library :: YAML . new
51+ add_lib 'yaml'
5252 end
5353
5454 def validations_command
55- add_lib Library :: Validations . new
55+ add_lib 'validations'
5656 end
5757
5858 def comp_command
5959 format = args [ 'FORMAT' ]
6060 output = args [ 'OUTPUT' ]
6161
6262 case format
63- when "script"
64- path = output || "#{ Settings . target_dir } /completions.bash"
65- add_lib Library ::CompletionsScript . new ( path )
66-
67- when "function"
68- function = output || "send_completions"
69- path = "#{ Settings . source_dir } /lib/#{ function } .sh"
70- add_lib Library ::CompletionsFunction . new ( path , function : function )
71-
72- when "yaml"
73- path = output || "#{ Settings . target_dir } /completions.yml"
74- add_lib Library ::CompletionsYAML . new ( path )
75-
76- else
77- raise Error , "Unrecognized format: #{ format } "
78-
63+ when "script" then add_lib 'completions_script' , output
64+ when "function" then add_lib 'completions' , output
65+ when "yaml" then add_lib 'completions_yaml' , output
66+ else raise Error , "Unrecognized format: #{ format } "
7967 end
8068
8169 end
8270
8371 private
8472
85- def add_lib ( handler )
73+ def add_lib ( name , *args )
74+ library = Bashly ::Library . new name , *args
8675 files_created = 0
87- handler . files . each do |file |
76+ library . files . each do |file |
8877 created = safe_write file [ :path ] , file [ :content ]
8978 files_created += 1 if created
9079 end
91- message = handler . post_install_message
80+ message = library . post_install_message
9281 say "\n #{ message } " if message and files_created > 0
9382 end
9483
0 commit comments