13 #ifndef __STOUT_FLAGS_PARSE_HPP__ 14 #define __STOUT_FLAGS_PARSE_HPP__ 38 std::istringstream in(value);
45 return Error(
"Failed to convert into required type");
59 if (value ==
"true" || value ==
"1") {
61 }
else if (value ==
"false" || value ==
"0") {
64 return Error(
"Expecting a boolean (e.g., true or false)");
116 LOG(WARNING) <<
"Specifying an absolute filename to read a command line " 117 "option out of without using 'file:// is deprecated and " 118 "will be removed in a future release. Simply adding " 119 "'file://' to the beginning of the path should eliminate " 124 return Error(
"Error reading file '" + value +
"': " + read.
error());
126 return JSON::parse<JSON::Object>(read.
get());
128 #endif // __WINDOWS__ 129 return JSON::parse<JSON::Object>(value);
146 LOG(WARNING) <<
"Specifying an absolute filename to read a command line " 147 "option out of without using 'file:// is deprecated and " 148 "will be removed in a future release. Simply adding " 149 "'file://' to the beginning of the path should eliminate " 154 return Error(
"Error reading file '" + value +
"': " + read.
error());
156 return JSON::parse<JSON::Array>(read.
get());
158 #endif // __WINDOWS__ 159 return JSON::parse<JSON::Array>(value);
174 result.
value = value;
177 const std::string
path = value.substr(7);
182 return Error(
"Error reading file '" + path +
"': " + read.
error());
199 if (fd.size() != 2) {
200 return Error(
"Expected to split string into exactly two parts.");
217 return Error(
"`int_fd` was neither a `HANDLE` nor a `SOCKET`");
219 #endif // __WINDOWS__ 230 std::vector<unsigned int> result;
236 return Error(
"Failed to numify '" + token +
"': " + number.
error());
239 result.push_back(number.
get());
255 std::set<std::string> result;
258 if (result.count(token) > 0) {
259 return Error(
"Duplicate token '" + token +
"'");
262 result.insert(token);
270 #endif // __STOUT_FLAGS_PARSE_HPP__ bool endsWith(const std::string &s, const std::string &suffix)
Definition: strings.hpp:402
Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
std::string value
Definition: flag.hpp:109
static Try< IPv6 > parse(const std::string &value)
Definition: ip.hpp:391
static Try< Bytes > parse(const std::string &s)
Definition: bytes.hpp:39
static Try< IP > parse(const std::string &value, int family=AF_UNSPEC)
Definition: ip.hpp:417
Option< Path > path
Definition: flag.hpp:108
std::vector< std::string > tokenize(const std::string &s, const std::string &delims, const Option< size_t > &maxTokens=None())
Definition: strings.hpp:139
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
Try< mesos::ACLs > parse(const std::string &value)
Returns the OCI v1 descriptor, image index, image manifest and image configuration from the given str...
Definition: parse.hpp:36
static Try error(const E &e)
Definition: try.hpp:43
static Try< Duration > parse(const std::string &s)
Definition: duration.hpp:363
Result< std::string > read(int_fd fd, size_t size)
Definition: read.hpp:55
bool isError() const
Definition: try.hpp:78
Result< Credentials > read(const Path &path)
Definition: credentials.hpp:35
std::vector< std::string > split(const std::string &s, const std::string &delims, const Option< size_t > &maxTokens=None())
Definition: strings.hpp:184
int int_fd
Definition: int_fd.hpp:35
bool startsWith(const std::string &s, const std::string &prefix)
Definition: strings.hpp:381
static Try< IPv4 > parse(const std::string &value)
Definition: ip.hpp:347