1 //===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/OptionGroupOutputFile.h"
12 #include "lldb/Host/OptionParser.h"
15 using namespace lldb_private;
17 OptionGroupOutputFile::OptionGroupOutputFile()
18 : m_file(), m_append(false, false) {}
20 OptionGroupOutputFile::~OptionGroupOutputFile() {}
22 static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
24 static constexpr OptionDefinition g_option_table[] = {
25 {LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
26 nullptr, {}, 0, eArgTypeFilename,
27 "Specify a path for capturing command output."},
28 {LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
29 OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
30 "Append to the file specified with '--outfile <path>'."},
33 llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {
34 return llvm::makeArrayRef(g_option_table);
38 OptionGroupOutputFile::SetOptionValue(uint32_t option_idx,
39 llvm::StringRef option_arg,
40 ExecutionContext *execution_context) {
42 const int short_option = g_option_table[option_idx].short_option;
44 switch (short_option) {
46 error = m_file.SetValueFromString(option_arg);
49 case SHORT_OPTION_APND:
50 m_append.SetCurrentValue(true);
54 error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
61 void OptionGroupOutputFile::OptionParsingStarting(
62 ExecutionContext *execution_context) {