22#include <CLI/Config.hpp>
23#include <CLI/Error.hpp>
29#include "glaze/glaze.hpp"
31#include "WebAssemblyInterfaceExport.h"
36#define ITK_WASM_PARSE(pipeline) \
39 const auto iwpArgc = (pipeline).get_argc(); \
40 const auto iwpArgv = (pipeline).get_argv(); \
41 for (int ii = 0; ii < iwpArgc; ++ii) \
43 const std::string arg(iwpArgv[ii]); \
44 if (arg == "-h" || arg == "--help") \
46 (pipeline).exit(CLI::CallForAllHelp()); \
49 if (arg == "--interface-json") \
51 (pipeline).interface_json(); \
54 if (arg == "--version") \
56 std::cout << "Version: " << (pipeline).version() << std::endl; \
62 catch (const CLI::ParseError & e) \
64 return (pipeline).exit(e); \
72#define ITK_WASM_PRE_PARSE(pipeline) \
75 (pipeline).set_help_flag(); \
76 (pipeline).allow_extras(true); \
79 catch (const CLI::CallForHelp & e) \
81 catch (const CLI::CallForAllHelp & e) \
83 catch (const CLI::ParseError & e) \
85 return (pipeline).exit(e); \
87 (pipeline).allow_extras(false); \
88 (pipeline).set_help_flag("-h,--help", "Print this help message and exit"); \
91#define ITK_WASM_CATCH_EXCEPTION(pipeline, command) \
96 catch (const itk::ExceptionObject & excp) \
98 std::ostringstream ostrm; \
100 ostrm << " In " __FILE__ ", line " << __LINE__ << std::endl; \
101 CLI::Error err("Runtime error", ostrm.str(), 1); \
102 return (pipeline).exit(err); \
104 catch (const std::exception & excp) \
106 std::ostringstream ostrm; \
107 ostrm << excp.what(); \
108 ostrm << " In " __FILE__ ", line " << __LINE__ << std::endl; \
109 CLI::Error err("Runtime error", ostrm.str(), 1); \
110 return (pipeline).exit(err); \
120using CLI::ExistingDirectory;
121using CLI::ExistingFile;
124using CLI::NonexistentPath;
126using CLI::ParseError;
137template <
typename TIteratorable>
141 glz::json_t::array_t value(container.begin(), container.end());
145class WebAssemblyInterface_EXPORT
Pipeline :
public CLI::App
149 Pipeline(std::string name, std::string description,
int argc,
char ** argv);
153 exit(
const CLI::Error & e) -> int;
static auto get_use_memory_io()
Pipeline(std::string name, std::string description, int argc, char **argv)
void set_version(const char *version)
std::string version() const
auto exit(const CLI::Error &e) -> int
static bool m_UseMemoryIO
glz::json_t::array_t getArrayJson(TIteratorable container)
Create a glaze arrat_t value from an STL style container.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....