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 
114  void SetStopOnUnrecognizedArgument(bool val);
115  bool GetStopOnUnrecognizedArgument() const;
117 
119 
125  vtkSetMacro(GenerateWarnings, bool);
126  vtkGetMacro(GenerateWarnings, bool);
127  vtkBooleanMacro(GenerateWarnings, bool);
129 
131 
145  vtkSetMacro(HandleLegacyArgumentFormats, bool);
146  vtkGetMacro(HandleLegacyArgumentFormats, bool);
147  vtkBooleanMacro(HandleLegacyArgumentFormats, bool);
149 
160  bool Parse(int& argc, char**& argv);
161 
163 
167  const std::vector<std::string>& GetExtraArguments() const { return this->ExtraArguments; }
169 
173  const std::string& GetLastErrorMessage() const { return this->LastErrorMessage; }
174 
178  vtkGetMacro(HelpRequested, bool);
179 
183  std::string GetUsage() const;
184 
185 protected:
186  vtkCLIOptions();
187  ~vtkCLIOptions() override;
188 
189 private:
190  vtkCLIOptions(const vtkCLIOptions&) = delete;
191  void operator=(const vtkCLIOptions&) = delete;
192 
193  class vtkInternals;
194  std::unique_ptr<vtkInternals> Internals;
195  bool HandleLegacyArgumentFormats = true;
196  bool GenerateWarnings = true;
197  std::vector<std::string> ExtraArguments;
198  std::string LastErrorMessage;
199  bool HelpRequested = false;
200  mutable std::string Help;
201  mutable std::string Description;
202 };
203 
204 #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.