#pragma once #include #include #include namespace sedpp { // A script can come from -e text or -f file text. Keeping the source kind lets // main.cpp reproduce GNU-style diagnostics before the compiler sees the script. struct ScriptSpec { bool isFile = false; std::string value; }; // Command-line options that affect both compilation and execution. The parser // keeps compatibility switches such as posix/strictPosix separate because some // behavior is merely POSIX-flavored while other behavior must reject GNU syntax. struct Options { bool quiet = false; bool extendedRegex = false; bool nullData = false; bool separate = false; bool sandbox = false; bool unbuffered = false; bool posix = false; bool strictPosix = false; bool debug = false; bool inPlace = false; bool followSymlinks = false; int lineLength = 0; std::string inPlaceSuffix; std::vector scripts; std::vector scriptFiles; std::vector scriptSpecs; std::vector inputFiles; }; // immediateExit is set for --help/--version and for parse-time usage errors // where sed should exit before compiling or reading input. struct ParseResult { Options options; int immediateExit = -1; }; class OptionParser { public: [[nodiscard]] ParseResult parse(int argc, char **argv) const; private: static void printHelp(bool includeEmail, bool toStdout); static void printVersion(); }; } // namespace sedpp