vtkCLIOptions.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
29 #ifndef vtkCLIOptions_h
30 #define vtkCLIOptions_h
31 
32 #include "vtkObject.h"
33 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
34 
35 #include <memory> // for std::unique_ptr
36 #include <string> // for std::string
37 #include <vector> // for std::vector
38 #include <vtk_cli11_forward.h> // for CLI::App
39 
40 // forward declare CLI::App
41 namespace CLI
42 {
43 class App;
44 }
45 
47 {
48 public:
49  static vtkCLIOptions* New();
50  vtkTypeMacro(vtkCLIOptions, vtkObject);
51  void PrintSelf(ostream& os, vtkIndent indent) override;
52 
58  static vtkCLIOptions* New(const std::shared_ptr<CLI::App>& app);
59 
64  CLI::App* GetCLI11App() const;
65 
69  const char* GetHelp() const;
70 
72 
76  void SetName(const char* name);
77  const char* GetName() const;
79 
81 
84  void SetDescription(const char* desc);
85  const char* GetDescription() const;
87 
89 
97  void SetAllowExtras(bool val);
98  bool GetAllowExtras() const;
100 
102 
110  void SetStopOnUnrecognizedArgument(bool val);
111  bool GetStopOnUnrecognizedArgument() const;
113 
115 
121  vtkSetMacro(GenerateWarnings, bool);
122  vtkGetMacro(GenerateWarnings, bool);
123  vtkBooleanMacro(GenerateWarnings, bool);
125 
127 
141  vtkSetMacro(HandleLegacyArgumentFormats, bool);
142  vtkGetMacro(HandleLegacyArgumentFormats, bool);
143  vtkBooleanMacro(HandleLegacyArgumentFormats, bool);
145 
156  bool Parse(int& argc, char**& argv);
157 
159 
163  const std::vector<std::string>& GetExtraArguments() const { return this->ExtraArguments; }
165 
169  const std::string& GetLastErrorMessage() const { return this->LastErrorMessage; }
170 
174  vtkGetMacro(HelpRequested, bool);
175 
179  std::string GetUsage() const;
180 
181 protected:
182  vtkCLIOptions();
183  ~vtkCLIOptions() override;
184 
185 private:
186  vtkCLIOptions(const vtkCLIOptions&) = delete;
187  void operator=(const vtkCLIOptions&) = delete;
188 
189  class vtkInternals;
190  std::unique_ptr<vtkInternals> Internals;
191  bool HandleLegacyArgumentFormats = true;
192  bool GenerateWarnings = true;
193  std::vector<std::string> ExtraArguments;
194  std::string LastErrorMessage;
195  bool HelpRequested = false;
196  mutable std::string Help;
197  mutable std::string Description;
198 };
199 
200 #endif
#define VTKPVVTKEXTENSIONSCORE_EXPORT
command line options manager
Definition: vtkCLIOptions.h:46
const std::vector< std::string > & GetExtraArguments() const
Returns unparsed / extra arguments left over from the most reset Parse call.
const std::string & GetLastErrorMessage() const
Returns error message from the most recent call to Parse, if any.