diff --git a/src/A3t.cpp b/src/A3t.cpp index 1aff82406..45d5e149a 100644 --- a/src/A3t.cpp +++ b/src/A3t.cpp @@ -444,41 +444,51 @@ void A3t::inject_defaults () std::string defaultCommand = context.config.get ("default.command"); if (defaultCommand != "") { -/* + std::cout << "# defaultCommand\n"; context.debug ("No command or sequence found - assuming default.command."); capture_first (defaultCommand); - context.header ("[" + combine () + "]"); -*/ + + std::string combined; + std::vector ::iterator i; + for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) + { + if (combined.length ()) + combined += ' '; + + combined += (*i)->attribute ("raw"); + } + + context.header ("[" + combined + "]"); } -/* else + { + std::cout << "# ! defaultCommand\n"; throw std::string (STRING_TRIVIAL_INPUT); -*/ + } } else { std::cout << "# found_sequence\n"; - +/* // Modify command. if (found_other) { std::cout << "# found_other\n"; -/* context.debug ("Sequence and filter, but no command found - assuming 'modify' command."); capture_first ("modify"); -*/ } // Information command. else { +*/ std::cout << "# ! found_other\n"; -/* context.debug ("Sequence but no command found - assuming 'information' command."); context.header (STRING_ASSUME_INFO); capture_first ("information"); -*/ +/* } +*/ } } } @@ -552,6 +562,24 @@ void A3t::resolve_aliases () */ } +//////////////////////////////////////////////////////////////////////////////// +void A3t::capture_first (const std::string& arg) +{ + std::cout << "# capture_first (" << arg << ")\n"; + + // Insert the arg as the new first branch. + Tree* t = new Tree ("argIns"); + t->attribute ("raw", arg); + t->tag ("?"); + t->_trunk = _tree; + + std::vector ::iterator i = _tree->_branches.begin (); + i++; // Walk past the binary. + + _tree->_branches.insert (i, t); + findCommand (); +} + //////////////////////////////////////////////////////////////////////////////// // /pattern/ void A3t::findPattern () diff --git a/src/A3t.h b/src/A3t.h index 48cc3e4da..8875e8a54 100644 --- a/src/A3t.h +++ b/src/A3t.h @@ -54,6 +54,7 @@ public: void apply_overrides (); void inject_defaults (); void resolve_aliases (); + void capture_first (const std::string&); private: void findBinary ();