diff --git a/src/commands/CmdReport.cpp b/src/commands/CmdReport.cpp index f5f77ad8..493b7ccf 100644 --- a/src/commands/CmdReport.cpp +++ b/src/commands/CmdReport.cpp @@ -26,9 +26,40 @@ #include #include +#include +#include #include #include +//////////////////////////////////////////////////////////////////////////////// +// Given a partial match for an extension script name, find the full patch of +// the extension it may match. +static std::string findExtension ( + Extensions& extensions, + const std::string& partial) +{ + auto scripts = extensions.all (); + std::vector options; + for (auto& script : scripts) + options.push_back (File (script).name ()); + + std::vector matches; + autoComplete (partial, options, matches, 3); + + if (matches.size () == 0) + throw format ("The report '{1}' is not recognized.", partial); + + if (matches.size () > 1) + throw format ("The report '{1}' is ambiguous, and could mean one of: {2}", + partial, + join (", ", matches)); + + // Now map matches[0] back to it's corresponding option. + for (auto& script : scripts) + if (File (script).name () == matches[0]) + return script; +} + //////////////////////////////////////////////////////////////////////////////// int CmdReport ( const std::vector & args,