1 //===-- CommandObjectDWIMPrint.h --------------------------------*- C++ -*-===//
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 
9 #ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTDWIMPRINT_H
10 #define LLDB_SOURCE_COMMANDS_COMMANDOBJECTDWIMPRINT_H
11 
12 #include "CommandObjectExpression.h"
13 #include "lldb/Interpreter/CommandObject.h"
14 #include "lldb/Interpreter/OptionGroupFormat.h"
15 #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
16 #include "lldb/Interpreter/OptionValueFormat.h"
17 
18 namespace lldb_private {
19 
20 /// Implements `dwim-print`, a printing command that chooses the most direct,
21 /// efficient, and resilient means of printing a given expression.
22 ///
23 /// DWIM is an acronym for Do What I Mean. From Wikipedia, DWIM is described as:
24 ///
25 ///   > attempt to anticipate what users intend to do, correcting trivial errors
26 ///   > automatically rather than blindly executing users' explicit but
27 ///   > potentially incorrect input
28 ///
29 /// The `dwim-print` command serves as a single print command for users who
30 /// don't yet know, or perfer not to know, the various lldb commands that can be
31 /// used to print, and when to use them.
32 class CommandObjectDWIMPrint : public CommandObjectRaw {
33 public:
34   CommandObjectDWIMPrint(CommandInterpreter &interpreter);
35 
36   ~CommandObjectDWIMPrint() override = default;
37 
38   Options *GetOptions() override;
39 
40   bool WantsCompletion() override { return true; }
41 
42   void
43   HandleArgumentCompletion(CompletionRequest &request,
44                            OptionElementVector &opt_element_vector) override;
45 
46 private:
47   bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
48 
49   OptionGroupOptions m_option_group;
50   OptionGroupFormat m_format_options = lldb::eFormatDefault;
51   OptionGroupValueObjectDisplay m_varobj_options;
52   CommandObjectExpression::CommandOptions m_expr_options;
53 };
54 
55 } // namespace lldb_private
56 
57 #endif
58