Lines Matching refs:args

34 bool Command::NextArgumentOrError(const std::vector<std::string>& args, size_t* pi) {  in NextArgumentOrError()  argument
35 if (*pi + 1 == args.size()) { in NextArgumentOrError()
36 LOG(ERROR) << "No argument following " << args[*pi] << " option. Try `simpleperf help " << name_ in NextArgumentOrError()
44 bool Command::PreprocessOptions(const std::vector<std::string>& args, in PreprocessOptions() argument
51 for (i = 0; i < args.size() && !args[i].empty() && args[i][0] == '-'; i++) { in PreprocessOptions()
52 auto it = option_formats.find(args[i]); in PreprocessOptions()
54 if (args[i] == "--") { in PreprocessOptions()
58 ReportUnknownOption(args, i); in PreprocessOptions()
66 if (i + 1 == args.size()) { in PreprocessOptions()
78 value.str_value = &args[++i]; in PreprocessOptions()
81 if (!args[i + 1].empty() && args[i + 1][0] != '-') { in PreprocessOptions()
82 value.str_value = &args[++i]; in PreprocessOptions()
86 if (!android::base::ParseUint(args[++i], &value.uint_value, in PreprocessOptions()
88 LOG(ERROR) << "Invalid argument for option " << name << ": " << args[i]; in PreprocessOptions()
93 if (!android::base::ParseDouble(args[++i], &value.double_value)) { in PreprocessOptions()
94 LOG(ERROR) << "Invalid argument for option " << name << ": " << args[i]; in PreprocessOptions()
117 if (i < args.size()) { in PreprocessOptions()
119 LOG(ERROR) << "Invalid option " << args[i] << ". Try `simpleperf help " << name_ << "`"; in PreprocessOptions()
122 non_option_args->assign(args.begin() + i, args.end()); in PreprocessOptions()
127 bool Command::GetDoubleOption(const std::vector<std::string>& args, size_t* pi, double* value, in GetDoubleOption() argument
129 if (!NextArgumentOrError(args, pi)) { in GetDoubleOption()
132 if (!android::base::ParseDouble(args[*pi].c_str(), value, min, max)) { in GetDoubleOption()
133 LOG(ERROR) << "Invalid argument for option " << args[*pi - 1] << ": " << args[*pi]; in GetDoubleOption()
139 void Command::ReportUnknownOption(const std::vector<std::string>& args, size_t i) { in ReportUnknownOption() argument
140 LOG(ERROR) << "Unknown option for " << name_ << " command: '" << args[i] in ReportUnknownOption()
223 std::vector<std::string> args; in RunSimpleperfCmd() local
233 args.emplace_back(std::move(option_name)); in RunSimpleperfCmd()
241 args.insert(args.begin(), "help"); in RunSimpleperfCmd()
260 args.emplace_back(argv[i++]); in RunSimpleperfCmd()
265 if (args.empty()) { in RunSimpleperfCmd()
266 args.push_back("help"); in RunSimpleperfCmd()
268 std::unique_ptr<Command> command = CreateCommandInstance(args[0]); in RunSimpleperfCmd()
270 LOG(ERROR) << "malformed command line: unknown command " << args[0]; in RunSimpleperfCmd()
273 std::string command_name = args[0]; in RunSimpleperfCmd()
274 args.erase(args.begin()); in RunSimpleperfCmd()
277 bool result = command->Run(args); in RunSimpleperfCmd()