A3t
- Testing structㄩre of A3t::inject_defaults.
This commit is contained in:
42
src/A3t.cpp
42
src/A3t.cpp
@@ -410,69 +410,77 @@ void A3t::apply_overrides ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// TODO
|
|
||||||
void A3t::inject_defaults ()
|
void A3t::inject_defaults ()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Scan the arguments and detect what is present.
|
|
||||||
bool found_command = false;
|
bool found_command = false;
|
||||||
bool found_sequence = false;
|
bool found_sequence = false;
|
||||||
bool found_other = false;
|
bool found_other = false;
|
||||||
|
|
||||||
std::vector <Arg>::iterator arg;
|
std::vector <Tree*>::iterator i;
|
||||||
for (arg = this->begin (); arg != this->end (); ++arg)
|
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||||
{
|
{
|
||||||
if (arg->_category == Arg::cat_command)
|
if ((*i)->hasTag ("CMD"))
|
||||||
found_command = true;
|
found_command = true;
|
||||||
|
|
||||||
// TODO no "id" or "uuid" categories exist at this time.
|
else if ((*i)->hasTag ("ID") || (*i)->hasTag ("UUID"))
|
||||||
// This kills the auto-info feature.
|
found_sequence = true;
|
||||||
// else if (arg->_category == Arg::cat_id ||
|
|
||||||
// arg->_category == Arg::cat_uuid)
|
|
||||||
// found_sequence = true;
|
|
||||||
|
|
||||||
else if (arg->_category != Arg::cat_program &&
|
else if (! (*i)->hasTag ("RC") &&
|
||||||
arg->_category != Arg::cat_override &&
|
! (*i)->hasTag ("CONFIG"))
|
||||||
arg->_category != Arg::cat_rc)
|
|
||||||
found_other = true;
|
found_other = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no command was specified, then a command will be inserted.
|
// If no command was specified, then a command will be inserted.
|
||||||
if (!found_command)
|
if (! found_command)
|
||||||
{
|
{
|
||||||
|
std::cout << "# ! found_command\n";
|
||||||
|
|
||||||
// Default command.
|
// Default command.
|
||||||
if (!found_sequence)
|
if (! found_sequence)
|
||||||
{
|
{
|
||||||
|
std::cout << "# ! found_sequence\n";
|
||||||
|
|
||||||
// Apply overrides, if any.
|
// Apply overrides, if any.
|
||||||
std::string defaultCommand = context.config.get ("default.command");
|
std::string defaultCommand = context.config.get ("default.command");
|
||||||
if (defaultCommand != "")
|
if (defaultCommand != "")
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
context.debug ("No command or sequence found - assuming default.command.");
|
context.debug ("No command or sequence found - assuming default.command.");
|
||||||
capture_first (defaultCommand);
|
capture_first (defaultCommand);
|
||||||
context.header ("[" + combine () + "]");
|
context.header ("[" + combine () + "]");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
throw std::string (STRING_TRIVIAL_INPUT);
|
throw std::string (STRING_TRIVIAL_INPUT);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::cout << "# found_sequence\n";
|
||||||
|
|
||||||
// Modify command.
|
// Modify command.
|
||||||
if (found_other)
|
if (found_other)
|
||||||
{
|
{
|
||||||
|
std::cout << "# found_other\n";
|
||||||
|
/*
|
||||||
context.debug ("Sequence and filter, but no command found - assuming 'modify' command.");
|
context.debug ("Sequence and filter, but no command found - assuming 'modify' command.");
|
||||||
capture_first ("modify");
|
capture_first ("modify");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information command.
|
// Information command.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::cout << "# ! found_other\n";
|
||||||
|
/*
|
||||||
context.debug ("Sequence but no command found - assuming 'information' command.");
|
context.debug ("Sequence but no command found - assuming 'information' command.");
|
||||||
context.header (STRING_ASSUME_INFO);
|
context.header (STRING_ASSUME_INFO);
|
||||||
capture_first ("information");
|
capture_first ("information");
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user