5 #ifndef CVMFS_PUBLISH_COMMAND_H_
6 #define CVMFS_PUBLISH_COMMAND_H_
45 const std::string &
key,
48 const std::string &desc,
52 , short_key(short_key)
55 , is_switch(is_switch)
56 , is_optional(is_optional)
59 assert(!is_switch || is_optional);
60 assert(is_optional || !arg_name.empty());
69 const std::string &desc)
71 return Parameter(key, short_key, arg_name, desc,
false,
false);
75 const std::string &desc)
77 return Parameter(key, short_key, arg_name, desc,
false,
true);
80 const std::string &desc)
82 return Parameter(key, short_key,
"", desc,
true,
true);
114 bool Has(
const std::string &key)
const {
117 bool HasNot(
const std::string &key)
const {
127 const std::string &default_value)
const
131 return default_value;
133 int GetInt(
const std::string &key)
const {
140 std::map<Parameter, Argument>
map_;
149 virtual std::string
GetName()
const = 0;
153 virtual std::string
GetBrief()
const = 0;
162 virtual std::string
GetUsage()
const {
return "[options]"; }
180 virtual int Main(
const Options &options) = 0;
189 return std::vector<std::string>();
211 #endif // CVMFS_PUBLISH_COMMAND_H_
bool operator!=(const Parameter &other) const
int GetInt(const std::string &key) const
std::string GetStringDefault(const std::string &key, const std::string &default_value) const
bool Has(const std::string &key) const
std::string GetString(const std::string &key) const
static Parameter Optional(const std::string &key, char short_key, const std::string &arg_name, const std::string &desc)
virtual bool IsHidden() const
virtual std::vector< std::string > DoGetExamples() const
bool operator<(const Parameter &other) const
void TakeCommand(Command *command)
std::string GetExamples() const
assert((mem||(size==0))&&"Out Of Memory")
Command * Find(const std::string &name)
const std::vector< Argument > & plain_args() const
std::map< Parameter, Argument > map_
const std::vector< Command * > & commands() const
bool operator==(const Parameter &other) const
int64_t String2Int64(const string &value)
static Parameter Switch(const std::string &key, char short_key, const std::string &desc)
Options ParseOptions(int argc, char **argv)
std::vector< Command * > commands_
Argument(const std::string &v)
static Parameter Mandatory(const std::string &key, char short_key, const std::string &arg_name, const std::string &desc)
virtual std::string GetDescription() const
std::vector< Parameter > ParameterList
void Set(const Parameter &p, const Argument &a)
virtual int Main(const Options &options)=0
virtual std::string GetUsage() const
bool HasNot(const std::string &key) const
Parameter(const std::string &key)
virtual ParameterList GetParams() const =0
std::vector< Argument > plain_args_
std::string progname() const
virtual std::string GetBrief() const =0
Argument Get(const std::string &key) const
virtual unsigned GetMinPlainArgs() const
void AppendPlain(const Argument &a)
virtual std::string GetName() const =0
Parameter(const std::string &key, char short_key, const std::string &arg_name, const std::string &desc, bool is_switch, bool is_optional)