39 typedef vector<swissknife::Command *>
Commands;
44 "CernVM-FS repository storage management commands\n"
46 "Usage (normally called from cvmfs_server):\n"
47 " cvmfs_swissknife <command> [options]\n",
54 for (
unsigned j = 0; j <
command_list[i]->GetName().length(); ++j) {
61 if (!params.empty()) {
63 for (
unsigned j = 0; j < params.size(); ++j) {
65 params[j].key(), params[j].description().c_str());
66 if (params[j].optional())
77 int main(
int argc,
char **argv) {
115 if ((
string(argv[1]) ==
"--help")) {
119 if ((
string(argv[1]) ==
"--version")) {
133 if (NULL == command) {
138 bool display_statistics =
false;
143 string option_string =
"";
145 for (
unsigned j = 0; j < params.size(); ++j) {
146 option_string.push_back(params[j].key());
147 if (!params[j].switch_only())
148 option_string.push_back(
':');
152 option_string.push_back(
':');
154 while ((c = getopt(argc, argv, option_string.c_str())) != -1) {
155 bool valid_option =
false;
156 for (
unsigned j = 0; j < params.size(); ++j) {
157 if (c == params[j].key()) {
161 if (!params[j].switch_only()) {
162 args[c].Reset(
new string(optarg));
171 Command::kGenericParamSeparator);
172 for (
unsigned i = 0; i < flags.size(); ++i) {
173 if (flags[i] ==
"stats") {
174 display_statistics =
true;
183 for (
unsigned j = 0; j < params.size(); ++j) {
184 if (!params[j].optional()) {
185 if (args.find(params[j].key()) == args.end()) {
195 const int retval = command->
Main(args);
198 if (display_statistics) {
207 const Commands::const_iterator iend =
command_list.end();
208 for (; i != iend; ++i) {
virtual ParameterList GetParams() const =0
std::string GetGMTimestamp(const std::string &format)
int Main(const ArgumentList &args)
std::vector< Parameter > ParameterList
static void Set(LogFacilities info, LogFacilities error)
virtual int Main(const ArgumentList &args)=0
assert((mem||(size==0))&&"Out Of Memory")
vector< string > SplitString(const string &str, char delim)
static const char kGenericParam
std::map< char, SharedPtr< std::string > > ArgumentList
std::string PrintList(const PrintOptions print_options)
vector< swissknife::Command * > Commands
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)