#include <CommandLine.h>
Classes | |
struct | Option |
Public Types | |
enum class | WrapInShell |
enum class | StringShellQuoting |
Public Member Functions | |
CommandLine ()=delete | |
nonvirtual void | Validate (Iterable< Option > options) const |
nonvirtual optional< String > | GetArgument (const Option &o) const |
nonvirtual Sequence< String > | GetArguments () const |
template<Common::IAnyOf< String > T, typename... ARGS> | |
nonvirtual T | As (ARGS... args) const |
Take in a 'command line' specification (typically from 'main', but also used as arguments to ProcessRunner), and define 'Option' objects and lookup if given arguments are 'present' in the commandline (and grab associated arguments).
Supports repeated option elements. Supports -o and –output-file formats Supports -o ARG and -o=ARG formats
inspired partly by https://man7.org/linux/man-pages/man3/getopt.3.html
TODO: o
Definition at line 82 of file CommandLine.h.
|
strong |
Used as optional CTOR argument, to create a CommandLine with bash -c "actual string arg" or cmd /C "actual string arg"
Definition at line 90 of file CommandLine.h.
|
strong |
Strategy/rules used when converting between a list of arguments to a single string.
Definition at line 262 of file CommandLine.h.
|
delete |
Unlike most other Stroika APIs, plain 'char' here for char*, is interpreted as being in the SDK code page (current locale - like SDKChar if narrow).
CommandLine{STRING} parsing the string into individual components the way a generic shell would (space separation) and respecting quote characters).
CommandLine{WrapInShell, STRING} really doesn't parse the string (except to add quotes as needed), but creates a CommandLine that will allow the argument shell to parse the command (e.g. bash -c "arguments").
CommandLine{Sequence<String>} just captures that sequence of arguments and does not processing/parsing.
CommandLine{argc,argv} are meant for being called from main, and also do no processing (besides treating the char* strings as SDKChar and mapping them from the OS codepage to UNICODE).
Throw InvalidCommandLineArgument if arguments not fit with options. This checks for unrecognized arguments.
Definition at line 319 of file CommandLine.cpp.
optional< String > Stroika::Foundation::Execution::CommandLine::GetArgument | ( | const Option & | o | ) | const |
Definition at line 35 of file CommandLine.inl.
overload with no arguments /0 - returns all commandline arguments.
Definition at line 41 of file CommandLine.inl.
nonvirtual T Stroika::Foundation::Execution::CommandLine::As | ( | ARGS... | args | ) | const |