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"
14 // Other libraries and framework includes
16 #include "lldb/Host/OptionParser.h"
19 using namespace lldb_private;
21 OptionGroupOutputFile::OptionGroupOutputFile()
22 : m_file(), m_append(false, false) {}
24 OptionGroupOutputFile::~OptionGroupOutputFile() {}
26 static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
28 static OptionDefinition g_option_table[] = {
29 {LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
30 nullptr, nullptr, 0, eArgTypeFilename,
31 "Specify a path for capturing command output."},
32 {LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
33 OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone,
34 "Append to the file specified with '--outfile <path>'."},
37 llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {
38 return llvm::makeArrayRef(g_option_table);
42 OptionGroupOutputFile::SetOptionValue(uint32_t option_idx,
43 llvm::StringRef option_arg,
44 ExecutionContext *execution_context) {
46 const int short_option = g_option_table[option_idx].short_option;
48 switch (short_option) {
50 error = m_file.SetValueFromString(option_arg);
53 case SHORT_OPTION_APND:
54 m_append.SetCurrentValue(true);
58 error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
65 void OptionGroupOutputFile::OptionParsingStarting(
66 ExecutionContext *execution_context) {