mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI2: Generalize 'add' to insert arguments at arbitrary position
This commit is contained in:
parent
9bc726ba61
commit
9128798fee
2 changed files with 6 additions and 5 deletions
|
@ -329,15 +329,16 @@ void CLI2::add (const std::string& argument)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Capture a set of arguments, inserted immediately after the binary.
|
||||
void CLI2::add (const std::vector <std::string>& arguments)
|
||||
// Capture a set of arguments, inserted immediately after <offset> arguments
|
||||
// after the binary..
|
||||
void CLI2::add (const std::vector <std::string>& arguments, int offset /* = 0 */)
|
||||
{
|
||||
std::vector <A2> replacement {_original_args[0]};
|
||||
std::vector <A2> replacement {_original_args.begin(), _original_args.begin() + offset + 1};
|
||||
|
||||
for (const auto& arg : arguments)
|
||||
replacement.push_back (A2 (arg, Lexer::Type::word));
|
||||
|
||||
for (unsigned int i = 1; i < _original_args.size (); ++i)
|
||||
for (unsigned int i = 1 + offset; i < _original_args.size (); ++i)
|
||||
replacement.push_back (_original_args[i]);
|
||||
|
||||
_original_args = replacement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue