From 6056ca4cd7426baec86d35f086399eec5fcff208 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 31 Oct 2014 23:11:40 -0400 Subject: [PATCH] CLI - Implemented ::getCommand. --- src/CLI.cpp | 11 +++++++++++ src/CLI.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index 760d7a1b6..ea9a4715c 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -464,6 +464,17 @@ bool CLI::canonicalize ( return false; } +//////////////////////////////////////////////////////////////////////////////// +std::string CLI::getCommand () const +{ + std::vector ::const_iterator a; + for (a = _args.begin (); a != _args.end (); ++a) + if (a->hasTag ("CMD")) + return a->attribute ("canonical"); + + return ""; +} + //////////////////////////////////////////////////////////////////////////////// const std::string CLI::dump (const std::string& title /* = "CLI Parser" */) const { diff --git a/src/CLI.h b/src/CLI.h index e6df50ff9..3c8a53a00 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -74,6 +74,7 @@ public: const std::vector getWords (); const std::vector getModifications (); bool canonicalize (std::string&, const std::string&, const std::string&) const; + std::string getCommand () const; const std::string dump (const std::string& title = "CLI Parser") const; private: