LLDB mainline
ScriptedInterfaceUsages.cpp
Go to the documentation of this file.
1//===-- ScriptedInterfaceUsages.cpp --------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
10
12
13using namespace lldb;
14using namespace lldb_private;
15
17 bool use_color) const {
18 const std::string label =
19 ansi::FormatAnsiTerminalCodes("${ansi.fg.green}${ansi.bold}", use_color);
20 const std::string dim =
21 ansi::FormatAnsiTerminalCodes("${ansi.faint}", use_color);
22 const std::string reset =
23 ansi::FormatAnsiTerminalCodes("${ansi.normal}", use_color);
24
25 s.IndentMore();
26 s.Indent();
27 llvm::StringRef usage_kind =
28 (kind == UsageKind::CommandInterpreter) ? "Command Interpreter" : "API";
29 s << label << usage_kind << " Usages:" << reset;
30 const std::vector<llvm::StringRef> &usages =
33 if (usages.empty())
34 s << ' ' << dim << "None" << reset << '\n';
35 else if (usages.size() == 1)
36 s << " " << usages.front() << '\n';
37 else {
38 s << '\n';
39 for (llvm::StringRef usage : usages) {
40 s.IndentMore();
41 s.Indent();
42 s << usage << '\n';
43 s.IndentLess();
44 }
45 }
46 s.IndentLess();
47}
void Dump(Stream &s, UsageKind kind, bool use_color=false) const
const std::vector< llvm::StringRef > & GetCommandInterpreterUsages() const
const std::vector< llvm::StringRef > & GetSBAPIUsages() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition Stream.cpp:157
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition Stream.cpp:204
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:201
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
A class that represents a running process on the host machine.