CLI/Context

- Removed repeated header calls that display a reconstructed command line in
  the event that default.command is used.
This commit is contained in:
Paul Beckingham 2014-11-10 22:07:02 -05:00
parent 65ca1ab84d
commit 97428397a5
2 changed files with 18 additions and 19 deletions

View file

@ -1799,9 +1799,6 @@ void CLI::injectDefaults ()
std::string defaultCommand = context.config.get ("default.command");
if (defaultCommand != "")
{
if (context.config.getBoolean ("debug"))
context.debug (std::string ("No command or sequence found - assuming default.command '") + defaultCommand + "'.");
// Split the defaultCommand into separate args.
std::vector <std::string> tokens;
Lexer::token_split (tokens, defaultCommand);
@ -1825,18 +1822,6 @@ void CLI::injectDefaults ()
}
_args = reconstructed;
// Extract a recomposed command line.
std::string combined;
for (a = _args.begin (); a != _args.end (); ++a)
{
if (combined.length ())
combined += ' ';
combined += a->attribute ("raw");
}
context.header ("[" + combined + "]");
}
// Only an error in strict mode.
@ -1847,10 +1832,6 @@ void CLI::injectDefaults ()
}
else
{
if (context.config.getBoolean ("debug"))
context.debug ("Sequence but no command found - assuming 'information' command.");
context.header (STRING_ASSUME_INFO);
A info ("argDefault", "information");
info.tag ("ASSUMED");
_args.push_back (info);

View file

@ -245,6 +245,24 @@ int Context::initialize (int argc, const char** argv)
cli.initialize (argc, argv);
cli.analyze (true, true);
// Extract a recomposed command line.
bool foundDefault = false;
std::string combined;
std::vector <A>::const_iterator a;
for (a = cli._args.begin (); a != cli._args.end (); ++a)
{
if (combined.length ())
combined += ' ';
combined += a->attribute ("raw");
if (a->hasTag ("DEFAULT"))
foundDefault = true;
}
if (foundDefault)
header ("[" + combined + "]");
////////////////////////////////////////////////////////////////////////////
//
// [8] Run on.launch hooks.