Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created rename_unique_agent method #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions extensions/expression.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,33 @@ end
-- end
-- return self:select_stage(self:last_stage());
-- end

function Expression.rename_unique_agent(self, agent_name, substitute_name)
local tag<const> = "REMANE_UNIT_AGENT";

if not self:loaded() then
warning(tag .. ": null at " .. PSR.source_line(2));
return self;
end

if agent_name == nil then
warning(tag .. ": agent name must not be nil");
return self;
end

if substitute_name == nil then
warning(tag .. ": substite name must not be nil");
return self;
end

local data_selected_agent = self:select_agent(agent_name):rename_agents({ substitute_name });

if not data_selected_agent:loaded() then
warning(tag .. ": " .. agent_name .. " not found");
return self;
end

local data_remoded_agent = self:remove_agent(agent_name);

return concatenate(data_selected_agent, data_remoded_agent);
end