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());
194 #endif // __STOUT_FLAGS_PARSE_HPP__
Definition: errorbase.hpp:35
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
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:145
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:42
Result< std::string > read(int_fd fd, size_t size)
Definition: read.hpp:50
#define flags
Definition: decoder.hpp:18
bool isError() const
Definition: try.hpp:71
Result< Credentials > read(const Path &path)
Definition: credentials.hpp:35
bool startsWith(const std::string &s, const std::string &prefix)
Definition: strings.hpp:380
static Try< IPv4 > parse(const std::string &value)
Definition: ip.hpp:347
static Try< Duration > parse(const std::string &s)
Definition: duration.hpp:35
const T & get() const
Definition: try.hpp:73