From 88fe152dbe940761805f5bc4dbacc4a51d34762e Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 2 Apr 2016 16:08:22 -0400 Subject: [PATCH] CLI: Added ::handleArg0 --- src/CLI.cpp | 15 +++++++++++++++ src/CLI.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/CLI.cpp b/src/CLI.cpp index ad69e83d..99b44498 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -135,12 +135,27 @@ void CLI::add (const std::string& argument) _args.clear (); } +//////////////////////////////////////////////////////////////////////////////// +// Arg0 is the first argument, which is the name and potentially a relative or +// absolute path to the invoked binary. +void CLI::handleArg0 () +{ + // Capture arg0 separately, because it is the command that was run, and could + // need special handling. + auto raw = _original_args[0].attribute ("raw"); + A2 a (raw, Lexer::Type::word); + a.tag ("BINARY"); + + _args.push_back (a); +} + //////////////////////////////////////////////////////////////////////////////// // Intended to be called after ::add() to perform the final analysis. void CLI::analyze () { // Process _original_args. _args.clear (); + handleArg0 (); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/CLI.h b/src/CLI.h index 9ab0f4f6..15ca6d21 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -62,6 +62,9 @@ public: bool canonicalize (std::string&, const std::string&, const std::string&) const; const std::string dump (const std::string& title = "CLI Parser") const; +private: + void handleArg0 (); + public: std::multimap _entities {}; std::vector _original_args {};