1 //===-- OptionGroupOutputFile.cpp -----------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Interpreter/OptionGroupOutputFile.h"
11 #include "lldb/Host/OptionParser.h"
14 using namespace lldb_private
;
16 OptionGroupOutputFile::OptionGroupOutputFile() : m_append(false, false) {}
18 static const uint32_t SHORT_OPTION_APND
= 0x61706e64; // 'apnd'
20 static constexpr OptionDefinition g_option_table
[] = {
21 {LLDB_OPT_SET_1
, false, "outfile", 'o', OptionParser::eRequiredArgument
,
22 nullptr, {}, 0, eArgTypeFilename
,
23 "Specify a path for capturing command output."},
24 {LLDB_OPT_SET_1
, false, "append-outfile", SHORT_OPTION_APND
,
25 OptionParser::eNoArgument
, nullptr, {}, 0, eArgTypeNone
,
26 "Append to the file specified with '--outfile <path>'."},
29 llvm::ArrayRef
<OptionDefinition
> OptionGroupOutputFile::GetDefinitions() {
30 return llvm::ArrayRef(g_option_table
);
34 OptionGroupOutputFile::SetOptionValue(uint32_t option_idx
,
35 llvm::StringRef option_arg
,
36 ExecutionContext
*execution_context
) {
38 const int short_option
= g_option_table
[option_idx
].short_option
;
40 switch (short_option
) {
42 error
= m_file
.SetValueFromString(option_arg
);
45 case SHORT_OPTION_APND
:
46 m_append
.SetCurrentValue(true);
50 llvm_unreachable("Unimplemented option");
56 void OptionGroupOutputFile::OptionParsingStarting(
57 ExecutionContext
*execution_context
) {