35 typedef vector<swissknife::Command *>
Commands;
40 "CernVM-FS repository storage management commands\n"
42 "Usage (normally called from cvmfs_server):\n"
43 " cvmfs_swissknife <command> [options]\n",
52 for (
unsigned j = 0; j <
command_list[i]->GetName().length(); ++j) {
59 if (!params.empty()) {
61 for (
unsigned j = 0; j < params.size(); ++j) {
63 params[j].key(), params[j].description().c_str());
64 if (params[j].optional())
75 int main(
int argc,
char **argv) {
113 if ((
string(argv[1]) ==
"--help")) {
117 if ((
string(argv[1]) ==
"--version")) {
131 if (NULL == command) {
136 bool display_statistics =
false;
141 string option_string =
"";
143 for (
unsigned j = 0; j < params.size(); ++j) {
144 option_string.push_back(params[j].key());
145 if (!params[j].switch_only())
146 option_string.push_back(
':');
150 option_string.push_back(
':');
152 while ((c = getopt(argc, argv, option_string.c_str())) != -1) {
153 bool valid_option =
false;
154 for (
unsigned j = 0; j < params.size(); ++j) {
155 if (c == params[j].key()) {
159 if (!params[j].switch_only()) {
160 args[c].Reset(
new string(optarg));
169 for (
unsigned i = 0; i < flags.size(); ++i) {
170 if (flags[i] ==
"stats") {
171 display_statistics =
true;
180 for (
unsigned j = 0; j < params.size(); ++j) {
181 if (!params[j].optional()) {
182 if (args.find(params[j].key()) == args.end()) {
192 const int retval = command->
Main(args);
195 if (display_statistics) {
205 const Commands::const_iterator iend =
command_list.end();
206 for (; i != iend; ++i) {
static const char kGenericParamSeparator
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,...)