diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-04-15 20:29:22 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-04-15 20:29:48 -0700 |
commit | 5886a92eb6dde5a406a62926f2914a908ca18d35 (patch) | |
tree | e7b70eb90a9bc39dc283b591d88ebe1bc012fbc5 /tools/aapt2/Flag.cpp | |
parent | 769de98f2dd41bfe39a1c9f76aefd1ad58942733 (diff) | |
download | frameworks_base-5886a92eb6dde5a406a62926f2914a908ca18d35.zip frameworks_base-5886a92eb6dde5a406a62926f2914a908ca18d35.tar.gz frameworks_base-5886a92eb6dde5a406a62926f2914a908ca18d35.tar.bz2 |
Fix up the command line, add flags.
Change-Id: I420bd0212fc7541668bd095b88295564d3d11f6c
Diffstat (limited to 'tools/aapt2/Flag.cpp')
-rw-r--r-- | tools/aapt2/Flag.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/aapt2/Flag.cpp b/tools/aapt2/Flag.cpp index a563bfc..3b2ff51 100644 --- a/tools/aapt2/Flag.cpp +++ b/tools/aapt2/Flag.cpp @@ -16,6 +16,7 @@ struct Flag { std::function<void(const StringPiece&)> action; bool required; bool* flagResult; + bool flagValueWhenSet; bool parsed; }; @@ -25,18 +26,19 @@ static std::vector<std::string> sArgs; void optionalFlag(const StringPiece& name, const StringPiece& description, std::function<void(const StringPiece&)> action) { sFlags.push_back( - Flag{ name.toString(), description.toString(), action, false, nullptr, false }); + Flag{ name.toString(), description.toString(), action, false, nullptr, false, false }); } void requiredFlag(const StringPiece& name, const StringPiece& description, std::function<void(const StringPiece&)> action) { sFlags.push_back( - Flag{ name.toString(), description.toString(), action, true, nullptr, false }); + Flag{ name.toString(), description.toString(), action, true, nullptr, false, false }); } -void optionalSwitch(const StringPiece& name, const StringPiece& description, bool* result) { - sFlags.push_back( - Flag{ name.toString(), description.toString(), {}, false, result, false }); +void optionalSwitch(const StringPiece& name, const StringPiece& description, bool resultWhenSet, + bool* result) { + sFlags.push_back(Flag{ + name.toString(), description.toString(), {}, false, result, resultWhenSet, false }); } void usageAndDie(const StringPiece& command) { @@ -73,7 +75,7 @@ void parse(int argc, char** argv, const StringPiece& command) { match = true; flag.parsed = true; if (flag.flagResult) { - *flag.flagResult = true; + *flag.flagResult = flag.flagValueWhenSet; } else { i++; if (i >= argc) { |