Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: tools/goopdump/goopdump_cmd_line_parser.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/goopdump/goopdump_cmd_line_parser.h ('k') | tools/goopdump/goopdump_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2008-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16
17 #include "omaha/tools/goopdump/goopdump_cmd_line_parser.h"
18
19 #include "omaha/common/debug.h"
20 #include "omaha/goopdate/command_line_parser.h"
21
22 namespace omaha {
23
24 HRESULT ParseGoopdumpCmdLine(int argc,
25 TCHAR** argv,
26 GoopdumpCmdLineArgs* args) {
27 ASSERT1(argc >= 1);
28 ASSERT1(argv);
29
30 UNREFERENCED_PARAMETER(argc);
31 UNREFERENCED_PARAMETER(argv);
32
33 CommandLineParser parser;
34 HRESULT hr = parser.ParseFromArgv(argc, argv);
35 if (FAILED(hr)) {
36 return hr;
37 }
38
39 std::vector<CString> valid_params;
40 valid_params.push_back(_T("dumpapps"));
41 valid_params.push_back(_T("oneclick"));
42 valid_params.push_back(_T("monitor"));
43 valid_params.push_back(_T("file"));
44
45 for (int i = 0; i < parser.GetSwitchCount(); ++i) {
46 CString switch_name;
47 parser.GetSwitchNameAtIndex(i, &switch_name);
48 bool found = false;
49 for (size_t i = 0; i < valid_params.size(); ++i) {
50 const CString& valid_param = valid_params[i];
51 if (valid_param.Compare(switch_name) == 0) {
52 found = true;
53 }
54 }
55 if (!found) {
56 return E_INVALIDARG;
57 }
58 }
59
60 if (parser.HasSwitch(_T("file"))) {
61 int arg_count = 0;
62 parser.GetSwitchArgumentCount(_T("file"), &arg_count);
63 if (arg_count != 1) {
64 return E_INVALIDARG;
65 }
66 args->is_write_to_file = true;
67 parser.GetSwitchArgumentValue(_T("file"), 0, &(args->log_filename));
68 }
69
70 if (parser.GetSwitchCount() == 0 ||
71 (parser.HasSwitch(_T("file")) && parser.GetSwitchCount() == 1)) {
72 // If you don't pass anything, give them everything except monitoring.
73 args->is_dump_general = true;
74 args->is_dump_app_manager = true;
75 args->is_dump_oneclick = true;
76 args->is_machine = true;
77 args->is_user = true;
78 }
79
80 if (parser.HasSwitch(_T("dumpapps"))) {
81 args->is_dump_general = true;
82 args->is_dump_app_manager = true;
83 args->is_machine = true;
84 args->is_user = true;
85 }
86
87 if (parser.HasSwitch(_T("oneclick"))) {
88 args->is_dump_general = true;
89 args->is_dump_oneclick = true;
90 args->is_machine = true;
91 args->is_user = true;
92 }
93
94 if (parser.HasSwitch(_T("monitor"))) {
95 args->is_monitor = true;
96 }
97
98 return S_OK;
99 }
100
101 } // namespace omaha
102
OLDNEW
« no previous file with comments | « tools/goopdump/goopdump_cmd_line_parser.h ('k') | tools/goopdump/goopdump_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698