mirror of
https://github.com/matrix-construct/construct
synced 2024-11-19 00:10:59 +01:00
modules/console: Add compose copy cmd.
This commit is contained in:
parent
60fcb54815
commit
7471417091
1 changed files with 39 additions and 0 deletions
|
@ -2644,6 +2644,45 @@ console_cmd__compose__final(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__compose__copy(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"srcid", "[dstid]"
|
||||
}};
|
||||
|
||||
const auto &srcid
|
||||
{
|
||||
param.at<uint>(0)
|
||||
};
|
||||
|
||||
const auto &dstid
|
||||
{
|
||||
param.at<uint>(1, compose.size())
|
||||
};
|
||||
|
||||
const auto &src
|
||||
{
|
||||
compose.at(srcid)
|
||||
};
|
||||
|
||||
if(compose.size() < dstid)
|
||||
throw error
|
||||
{
|
||||
"Cannot compose position %d without composing %d first", dstid, compose.size()
|
||||
};
|
||||
|
||||
if(compose.size() == dstid)
|
||||
{
|
||||
compose.emplace_back(src);
|
||||
return true;
|
||||
}
|
||||
|
||||
compose.at(dstid) = src;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__compose__clear(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue