warnings/exception because of already used aliases more verbose.

This commit is contained in:
Denis Knauf 2021-12-31 15:13:40 +01:00
parent a630da465a
commit ba922fe52c

View file

@ -120,17 +120,17 @@ class DenCli::Sub
name = name.to_s unless name.nil?
@subs[name] = obj
if @noshortaliases
warn "Command/Alias already exists: #{full_cmd.join ' '} #{name}" if @aliases.has_key? name
warn "Command/Alias for [#{obj.full_cmd}] already exists: #{full_cmd.join ' '} #{name}. Used by: #{@aliases[name].full_cmd}" if @aliases.has_key? name
@aliases[name] = obj
else
DenCli.gen_aliases name, min do |a|
warn "Command/Alias already exists: #{full_cmd.join ' '} #{a}" if @aliases.has_key? a
warn "Command/Alias for [#{obj.full_cmd}] already exists: #{full_cmd.join ' '} #{a}. Used by: #{@aliases[a].full_cmd}" if @aliases.has_key? a
@aliases[a] ||= obj
end
end
if aliases
[*aliases].each do |a|
raise ArgumentError, "Alias already exists: #{full_cmd.join ' '} #{a}" if @aliases.has_key? a
raise ArgumentError, "Alias for [#{obj.full_cmd}] already exists: #{full_cmd.join ' '} #{a}. Used by: #{@aliases[a].full_cmd}" if @aliases.has_key? a
@aliases[a] = obj
end
end