2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
33 #include "stg/servconf.h"
34 #include "stg/user_conf.h"
35 #include "stg/user_stat.h"
36 #include "stg/common.h"
57 typedef typename T::value_type type;
61 struct ARRAY_TYPE<T[]>
66 template <typename T, size_t N>
67 struct ARRAY_TYPE<T[N]>
73 struct nullary_function
75 typedef T result_type;
79 class binder0 : public nullary_function<typename F::result_type>
82 binder0(const F & func, const typename F::argument_type & arg)
83 : m_func(func), m_arg(arg) {}
84 typename F::result_type operator()() const { return m_func(m_arg); }
87 typename F::argument_type m_arg;
92 binder0<F> bind0(const F & func, const typename F::argument_type & arg)
94 return binder0<F>(func, arg);
97 template <typename C, typename A, typename R>
98 class METHOD1_ADAPTER : public std::unary_function<A, R>
101 METHOD1_ADAPTER(R (C::* func)(A), C & obj) : m_func(func), m_obj(obj) {}
102 R operator()(A arg) { return (m_obj.*m_func)(arg); }
108 template <typename C, typename A, typename R>
109 class CONST_METHOD1_ADAPTER : public std::unary_function<A, R>
112 CONST_METHOD1_ADAPTER(R (C::* func)(A) const, C & obj) : m_func(func), m_obj(obj) {}
113 R operator()(A arg) const { return (m_obj.*m_func)(arg); }
115 R (C::* m_func)(A) const;
119 template <typename C, typename A, typename R>
120 METHOD1_ADAPTER<C, A, R> Method1Adapt(R (C::* func)(A), C & obj)
122 return METHOD1_ADAPTER<C, A, R>(func, obj);
125 template <typename C, typename A, typename R>
126 CONST_METHOD1_ADAPTER<C, A, R> Method1Adapt(R (C::* func)(A) const, C & obj)
128 return CONST_METHOD1_ADAPTER<C, A, R>(func, obj);
131 template <typename T>
132 bool SetArrayItem(T & array, const char * index, const typename ARRAY_TYPE<T>::type & value)
135 if (str2x(index, pos))
141 void RawXMLCallback(bool result, const std::string & reason, const std::string & response, void * /*data*/)
145 std::cerr << "Failed to get raw XML response. Reason: '" << reason << "'." << std::endl;
148 SGCONF::PrintXML(response);
153 void UsageImpl(bool full);
154 void UsageConnection();
155 void UsageAdmins(bool full);
156 void UsageTariffs(bool full);
157 void UsageUsers(bool full);
158 void UsageServices(bool full);
159 void UsageCorporations(bool full);
163 void ReadUserConfigFile(SGCONF::OPTION_BLOCK & block)
165 std::vector<std::string> paths;
166 const char * configHome = getenv("XDG_CONFIG_HOME");
167 if (configHome == NULL)
169 const char * home = getenv("HOME");
172 paths.push_back(std::string(home) + "/.config/sgconf/sgconf.conf");
173 paths.push_back(std::string(home) + "/.sgconf/sgconf.conf");
176 paths.push_back(std::string(configHome) + "/sgconf/sgconf.conf");
177 for (std::vector<std::string>::const_iterator it = paths.begin(); it != paths.end(); ++it)
178 if (access(it->c_str(), R_OK) == 0)
180 block.ParseFile(*it);
185 } // namespace anonymous
190 class CONFIG_ACTION : public ACTION
193 CONFIG_ACTION(SGCONF::CONFIG & config,
194 const std::string & paramDescription)
196 m_description(paramDescription)
199 virtual ACTION * Clone() const { return new CONFIG_ACTION(*this); }
201 virtual std::string ParamDescription() const { return m_description; }
202 virtual std::string DefaultDescription() const { return ""; }
203 virtual OPTION_BLOCK & Suboptions() { return m_suboptions; }
204 virtual PARSER_STATE Parse(int argc, char ** argv);
207 SGCONF::CONFIG & m_config;
208 std::string m_description;
209 OPTION_BLOCK m_suboptions;
211 void ParseCredentials(const std::string & credentials);
212 void ParseHostAndPort(const std::string & hostAndPort);
215 typedef bool (* API_FUNCTION) (const SGCONF::CONFIG &,
217 const std::map<std::string, std::string> &);
222 COMMAND(API_FUNCTION funPtr,
223 const std::string & arg,
224 const std::map<std::string, std::string> & options)
229 bool Execute(const SGCONF::CONFIG & config) const
231 return m_funPtr(config, m_arg, m_options);
235 API_FUNCTION m_funPtr;
237 std::map<std::string, std::string> m_options;
243 void Add(API_FUNCTION funPtr,
244 const std::string & arg,
245 const std::map<std::string, std::string> & options) { m_commands.push_back(COMMAND(funPtr, arg, options)); }
246 bool Execute(const SGCONF::CONFIG & config) const
248 std::list<COMMAND>::const_iterator it(m_commands.begin());
250 while (it != m_commands.end() && res)
252 res = res && it->Execute(config);
258 std::list<COMMAND> m_commands;
261 class API_ACTION : public ACTION
264 API_ACTION(COMMANDS & commands,
265 const std::string & paramDescription,
267 const OPTION_BLOCK& suboptions,
269 : m_commands(commands),
270 m_description(paramDescription),
271 m_argument(needArgument ? "1" : ""), // Hack
272 m_suboptions(suboptions),
275 API_ACTION(COMMANDS & commands,
276 const std::string & paramDescription,
279 : m_commands(commands),
280 m_description(paramDescription),
281 m_argument(needArgument ? "1" : ""), // Hack
285 virtual ACTION * Clone() const { return new API_ACTION(*this); }
287 virtual std::string ParamDescription() const { return m_description; }
288 virtual std::string DefaultDescription() const { return ""; }
289 virtual OPTION_BLOCK & Suboptions() { return m_suboptions; }
290 virtual PARSER_STATE Parse(int argc, char ** argv)
292 PARSER_STATE state(false, argc, argv);
293 if (!m_argument.empty())
298 throw ERROR("Missing argument.");
303 m_suboptions.Parse(state.argc, state.argv);
304 m_commands.Add(m_funPtr, m_argument, m_params);
309 COMMANDS & m_commands;
310 std::string m_description;
311 std::string m_argument;
312 OPTION_BLOCK m_suboptions;
313 std::map<std::string, std::string> m_params;
314 API_FUNCTION m_funPtr;
317 PARSER_STATE CONFIG_ACTION::Parse(int argc, char ** argv)
322 throw ERROR("Missing argument.");
323 char * pos = strchr(*argv, '@');
326 ParseCredentials(std::string(*argv, pos));
327 ParseHostAndPort(std::string(pos + 1));
331 ParseHostAndPort(std::string(*argv));
333 return PARSER_STATE(false, --argc, ++argv);
336 void CONFIG_ACTION::ParseCredentials(const std::string & credentials)
338 std::string::size_type pos = credentials.find_first_of(':');
339 if (pos != std::string::npos)
341 m_config.userName = credentials.substr(0, pos);
342 m_config.userPass = credentials.substr(pos + 1);
346 m_config.userName = credentials;
350 void CONFIG_ACTION::ParseHostAndPort(const std::string & hostAndPort)
352 std::string::size_type pos = hostAndPort.find_first_of(':');
353 if (pos != std::string::npos)
355 m_config.server = hostAndPort.substr(0, pos);
357 if (str2x(hostAndPort.substr(pos + 1), port))
358 throw ERROR("Invalid port value: '" + hostAndPort.substr(pos + 1) + "'");
359 m_config.port = port;
363 m_config.server = hostAndPort;
368 CONFIG_ACTION * MakeParamAction(SGCONF::CONFIG & config,
369 const std::string & paramDescription)
371 return new CONFIG_ACTION(config, paramDescription);
375 ACTION * MakeAPIAction(COMMANDS & commands,
376 const std::string & paramDescription,
380 return new API_ACTION(commands, paramDescription, needArgument, funPtr);
384 ACTION * MakeAPIAction(COMMANDS & commands,
387 return new API_ACTION(commands, "", false, funPtr);
390 bool RawXMLFunction(const SGCONF::CONFIG & config,
391 const std::string & arg,
392 const std::map<std::string, std::string> & /*options*/)
394 STG::SERVCONF proto(config.server.data(),
396 config.userName.data(),
397 config.userPass.data());
398 return proto.RawXML(arg, RawXMLCallback, NULL) == STG::st_ok;
401 } // namespace SGCONF
405 //-----------------------------------------------------------------------------
406 int main(int argc, char **argv)
408 SGCONF::CONFIG config;
409 SGCONF::COMMANDS commands;
411 SGCONF::OPTION_BLOCKS blocks;
412 blocks.Add("General options")
413 .Add("c", "config", SGCONF::MakeParamAction(config.configFile, std::string("~/.config/stg/sgconf.conf"), "<config file>"), "override default config file")
414 .Add("h", "help", SGCONF::MakeFunc0Action(bind0(Method1Adapt(&SGCONF::OPTION_BLOCKS::Help, blocks), 0)), "\t\tshow this help and exit")
415 .Add("help-all", SGCONF::MakeFunc0Action(UsageAll), "\t\tshow full help and exit")
416 .Add("v", "version", SGCONF::MakeFunc0Action(Version), "\t\tshow version information and exit");
417 SGCONF::OPTION_BLOCK & block = blocks.Add("Connection options")
418 .Add("s", "server", SGCONF::MakeParamAction(config.server, std::string("localhost"), "<address>"), "\t\thost to connect")
419 .Add("p", "port", SGCONF::MakeParamAction(config.port, uint16_t(5555), "<port>"), "\t\tport to connect")
420 .Add("u", "username", SGCONF::MakeParamAction(config.userName, std::string("admin"), "<username>"), "\tadministrative login")
421 .Add("w", "userpass", SGCONF::MakeParamAction(config.userPass, "<password>"), "\tpassword for the administrative login")
422 .Add("a", "address", SGCONF::MakeParamAction(config, "<connection string>"), "connection params as a single string in format: <login>:<password>@<host>:<port>");
423 blocks.Add("Raw XML")
424 .Add("r", "raw", SGCONF::MakeAPIAction(commands, "<xml>", true, SGCONF::RawXMLFunction), "\tmake raw XML request");
425 blocks.Add("Admin management options")
426 .Add("get-admins", SGCONF::MakeAPIAction(commands, SGCONF::GetAdminsFunction), "\tget admin list")
427 .Add("get-admin", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::GetAdminFunction), "get admin")
428 .Add("add-admin", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::AddAdminFunction), "add admin")
429 .Add("del-admin", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::DelAdminFunction), "del admin")
430 .Add("chg-admin", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::ChgAdminFunction), "change admin");
431 blocks.Add("Tariff management options")
432 .Add("get-tariffs", SGCONF::MakeAPIAction(commands, SGCONF::GetTariffsFunction), "\tget tariff list")
433 .Add("get-tariff", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::GetTariffFunction), "get tariff")
434 .Add("add-tariff", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::AddTariffFunction), "add tariff")
435 .Add("del-tariff", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::DelTariffFunction), "del tariff")
436 .Add("chg-tariff", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::ChgTariffFunction), "change tariff");
437 blocks.Add("User management options")
438 .Add("get-users", SGCONF::MakeAPIAction(commands, SGCONF::GetUsersFunction), "\tget user list")
439 .Add("get-user", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::GetUserFunction), "get user")
440 .Add("add-user", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::AddUserFunction), "add user")
441 .Add("del-user", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::DelUserFunction), "del user")
442 .Add("chg-user", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::ChgUserFunction), "change user")
443 .Add("check-user", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::CheckUserFunction), "check user existance and credentials")
444 .Add("send-message", SGCONF::MakeAPIAction(commands, "<login>", true, SGCONF::SendMessageFunction), "send message");
445 blocks.Add("Service management options")
446 .Add("get-services", SGCONF::MakeAPIAction(commands, SGCONF::GetServicesFunction), "\tget service list")
447 .Add("get-service", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::GetServiceFunction), "get service")
448 .Add("add-service", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::AddServiceFunction), "add service")
449 .Add("del-service", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::DelServiceFunction), "del service")
450 .Add("chg-service", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::ChgServiceFunction), "change service");
451 blocks.Add("Corporation management options")
452 .Add("get-corps", SGCONF::MakeAPIAction(commands, SGCONF::GetCorpsFunction), "\tget corporation list")
453 .Add("get-corp", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::GetCorpFunction), "get corporation")
454 .Add("add-corp", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::AddCorpFunction), "add corporation")
455 .Add("del-corp", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::DelCorpFunction), "del corporation")
456 .Add("chg-corp", SGCONF::MakeAPIAction(commands, "<name>", true, SGCONF::ChgCorpFunction), "change corporation");
458 SGCONF::PARSER_STATE state(false, argc, argv);
462 state = blocks.Parse(--argc, ++argv); // Skipping self name
464 catch (const SGCONF::OPTION::ERROR& ex)
466 std::cerr << ex.what() << "\n";
475 std::cerr << "Unknown option: '" << *state.argv << "'\n";
481 SGCONF::CONFIG configOverride(config);
483 if (config.configFile.empty())
485 const char * mainConfigFile = "/etc/sgconf/sgconf.conf";
486 if (access(mainConfigFile, R_OK) == 0)
487 block.ParseFile(mainConfigFile);
488 ReadUserConfigFile(block);
492 block.ParseFile(config.configFile.data());
495 config = configOverride;
497 catch (const std::exception& ex)
499 std::cerr << ex.what() << "\n";
503 std::cerr << "Config: " << config.Serialize() << std::endl;
504 return commands.Execute(config) ? 0 : -1;
517 exit(PARAMETER_PARSING_ERR_CODE);
520 if (strcmp(argv[1], "get") == 0)
523 return mainGet(argc - 1, argv + 1);
525 else if (strcmp(argv[1], "set") == 0)
528 if (mainSet(argc - 1, argv + 1) )
535 exit(PARAMETER_PARSING_ERR_CODE);
537 return UNKNOWN_ERR_CODE;*/
539 //-----------------------------------------------------------------------------
554 void UsageImpl(bool full)
556 std::cout << "sgconf is the Stargazer management utility.\n\n"
558 << "\tsgconf [options]\n\n"
559 << "General options:\n"
560 << "\t-c, --config <config file>\t\toverride default config file (default: \"~/.config/stg/sgconf.conf\")\n"
561 << "\t-h, --help\t\t\t\tshow this help and exit\n"
562 << "\t--help-all\t\t\t\tshow full help and exit\n"
563 << "\t-v, --version\t\t\t\tshow version information and exit\n\n";
569 UsageCorporations(full);
571 //-----------------------------------------------------------------------------
572 void UsageConnection()
574 std::cout << "Connection options:\n"
575 << "\t-s, --server <address>\t\t\thost to connect (ip or domain name, default: \"localhost\")\n"
576 << "\t-p, --port <port>\t\t\tport to connect (default: \"5555\")\n"
577 << "\t-u, --username <username>\t\tadministrative login (default: \"admin\")\n"
578 << "\t-w, --userpass <password>\t\tpassword for administrative login\n"
579 << "\t-a, --address <connection string>\tconnection params as a single string in format: <login>:<password>@<host>:<port>\n\n";
581 //-----------------------------------------------------------------------------
582 void UsageAdmins(bool full)
584 std::cout << "Admins management options:\n"
585 << "\t--get-admins\t\t\t\tget a list of admins (subsequent options will define what to show)\n";
587 std::cout << "\t\t--login\t\t\t\tshow admin's login\n"
588 << "\t\t--priv\t\t\t\tshow admin's priviledges\n\n";
589 std::cout << "\t--get-admin\t\t\t\tget the information about admin\n";
591 std::cout << "\t\t--login <login>\t\t\tlogin of the admin to show\n"
592 << "\t\t--priv\t\t\t\tshow admin's priviledges\n\n";
593 std::cout << "\t--add-admin\t\t\t\tadd a new admin\n";
595 std::cout << "\t\t--login <login>\t\t\tlogin of the admin to add\n"
596 << "\t\t--password <password>\t\tpassword of the admin to add\n"
597 << "\t\t--priv <priv number>\t\tpriviledges of the admin to add\n\n";
598 std::cout << "\t--del-admin\t\t\t\tdelete an existing admin\n";
600 std::cout << "\t\t--login <login>\t\t\tlogin of the admin to delete\n\n";
601 std::cout << "\t--chg-admin\t\t\t\tchange an existing admin\n";
603 std::cout << "\t\t--login <login>\t\t\tlogin of the admin to change\n"
604 << "\t\t--priv <priv number>\t\tnew priviledges\n\n";
606 //-----------------------------------------------------------------------------
607 void UsageTariffs(bool full)
609 std::cout << "Tariffs management options:\n"
610 << "\t--get-tariffs\t\t\t\tget a list of tariffs (subsequent options will define what to show)\n";
612 std::cout << "\t\t--name\t\t\t\tshow tariff's name\n"
613 << "\t\t--fee\t\t\t\tshow tariff's fee\n"
614 << "\t\t--free\t\t\t\tshow tariff's prepaid traffic in terms of cost\n"
615 << "\t\t--passive-cost\t\t\tshow tariff's cost of \"freeze\"\n"
616 << "\t\t--traff-type\t\t\tshow what type of traffix will be accounted by the tariff\n"
617 << "\t\t--dirs\t\t\t\tshow tarification rules for directions\n\n";
618 std::cout << "\t--get-tariff\t\t\t\tget the information about tariff\n";
620 std::cout << "\t\t--name <name>\t\t\tname of the tariff to show\n"
621 << "\t\t--fee\t\t\t\tshow tariff's fee\n"
622 << "\t\t--free\t\t\t\tshow tariff's prepaid traffic in terms of cost\n"
623 << "\t\t--passive-cost\t\t\tshow tariff's cost of \"freeze\"\n"
624 << "\t\t--traff-type\t\t\tshow what type of traffix will be accounted by the tariff\n"
625 << "\t\t--dirs\t\t\t\tshow tarification rules for directions\n\n";
626 std::cout << "\t--add-tariff\t\t\t\tadd a new tariff\n";
628 std::cout << "\t\t--name <name>\t\t\tname of the tariff to add\n"
629 << "\t\t--fee <fee>\t\t\tstariff's fee\n"
630 << "\t\t--free <free>\t\t\ttariff's prepaid traffic in terms of cost\n"
631 << "\t\t--passive-cost <cost>\t\ttariff's cost of \"freeze\"\n"
632 << "\t\t--traff-type <type>\t\twhat type of traffi will be accounted by the tariff\n"
633 << "\t\t--times <times>\t\t\tslash-separated list of \"day\" time-spans (in form \"hh:mm-hh:mm\") for each direction\n"
634 << "\t\t--prices-day-a <prices>\t\tslash-separated list of prices for \"day\" traffic before threshold for each direction\n"
635 << "\t\t--prices-night-a <prices>\tslash-separated list of prices for \"night\" traffic before threshold for each direction\n"
636 << "\t\t--prices-day-b <prices>\t\tslash-separated list of prices for \"day\" traffic after threshold for each direction\n"
637 << "\t\t--prices-night-b <prices>\tslash-separated list of prices for \"night\" traffic after threshold for each direction\n"
638 << "\t\t--single-prices <yes|no>\tslash-separated list of \"single price\" flags for each direction\n"
639 << "\t\t--no-discounts <yes|no>\t\tslash-separated list of \"no discount\" flags for each direction\n"
640 << "\t\t--thresholds <thresholds>\tslash-separated list of thresholds (in Mb) for each direction\n\n";
641 std::cout << "\t--del-tariff\t\t\t\tdelete an existing tariff\n";
643 std::cout << "\t\t--name <name>\t\t\tname of the tariff to delete\n\n";
644 std::cout << "\t--chg-tariff\t\t\t\tchange an existing tariff\n";
646 std::cout << "\t\t--name <name>\t\t\tname of the tariff to change\n"
647 << "\t\t--fee <fee>\t\t\tstariff's fee\n"
648 << "\t\t--free <free>\t\t\ttariff's prepaid traffic in terms of cost\n"
649 << "\t\t--passive-cost <cost>\t\ttariff's cost of \"freeze\"\n"
650 << "\t\t--traff-type <type>\t\twhat type of traffix will be accounted by the tariff\n"
651 << "\t\t--dir <N>\t\t\tnumber of direction data to change\n"
652 << "\t\t\t--time <time>\t\t\"day\" time-span (in form \"hh:mm-hh:mm\")\n"
653 << "\t\t\t--price-day-a <price>\tprice for \"day\" traffic before threshold\n"
654 << "\t\t\t--price-night-a <price>\tprice for \"night\" traffic before threshold\n"
655 << "\t\t\t--price-day-b <price>\tprice for \"day\" traffic after threshold\n"
656 << "\t\t\t--price-night-b <price>\tprice for \"night\" traffic after threshold\n"
657 << "\t\t\t--single-price <yes|no>\t\"single price\" flag\n"
658 << "\t\t\t--no-discount <yes|no>\t\"no discount\" flag\n"
659 << "\t\t\t--threshold <threshold>\tthreshold (in Mb)\n\n";
661 //-----------------------------------------------------------------------------
662 void UsageUsers(bool full)
664 std::cout << "Users management options:\n"
665 << "\t--get-users\t\t\t\tget a list of users (subsequent options will define what to show)\n";
668 std::cout << "\t--get-user\t\t\t\tget the information about user\n";
671 std::cout << "\t--add-user\t\t\t\tadd a new user\n";
674 std::cout << "\t--del-user\t\t\t\tdelete an existing user\n";
677 std::cout << "\t--chg-user\t\t\t\tchange an existing user\n";
680 std::cout << "\t--check-user\t\t\t\tcheck credentials is valid\n";
683 std::cout << "\t--send-message\t\t\t\tsend a message to a user\n";
687 //-----------------------------------------------------------------------------
688 void UsageServices(bool full)
690 std::cout << "Services management options:\n"
691 << "\t--get-services\t\t\t\tget a list of services (subsequent options will define what to show)\n";
693 std::cout << "\t\t--name\t\t\t\tshow service's name\n"
694 << "\t\t--comment\t\t\tshow a comment to the service\n"
695 << "\t\t--cost\t\t\t\tshow service's cost\n"
696 << "\t\t--pay-day\t\t\tshow service's pay day\n\n";
697 std::cout << "\t--get-service\t\t\t\tget the information about service\n";
699 std::cout << "\t\t--name <name>\t\t\tname of the service to show\n"
700 << "\t\t--comment\t\t\tshow a comment to the service\n"
701 << "\t\t--cost\t\t\t\tshow service's cost\n"
702 << "\t\t--pay-day\t\t\tshow service's pay day\n\n";
703 std::cout << "\t--add-service\t\t\t\tadd a new service\n";
705 std::cout << "\t\t--name <name>\t\t\tname of the service to add\n"
706 << "\t\t--comment <comment>\t\ta comment to the service\n"
707 << "\t\t--cost <cost>\t\t\tservice's cost\n"
708 << "\t\t--pay-day <day>\t\t\tservice's pay day\n\n";
709 std::cout << "\t--del-service\t\t\t\tdelete an existing service\n";
711 std::cout << "\t\t--name <name>\t\t\tname of the service to delete\n\n";
712 std::cout << "\t--chg-service\t\t\t\tchange an existing service\n";
714 std::cout << "\t\t--name <name>\t\t\tname of the service to change\n"
715 << "\t\t--comment <comment>\t\ta comment to the service\n"
716 << "\t\t--cost <cost>\t\t\tservice's cost\n"
717 << "\t\t--pay-day <day>\t\t\tservice's pay day\n\n";
719 //-----------------------------------------------------------------------------
720 void UsageCorporations(bool full)
722 std::cout << "Corporations management options:\n"
723 << "\t--get-corporations\t\t\tget a list of corporations (subsequent options will define what to show)\n";
725 std::cout << "\t\t--name\t\t\t\tshow corporation's name\n"
726 << "\t\t--cash\t\t\t\tshow corporation's cash\n\n";
727 std::cout << "\t--get-corp\t\t\t\tget the information about corporation\n";
729 std::cout << "\t\t--name <name>\t\t\tname of the corporation to show\n"
730 << "\t\t--cash\t\t\t\tshow corporation's cash\n\n";
731 std::cout << "\t--add-corp\t\t\t\tadd a new corporation\n";
733 std::cout << "\t\t--name <name>\t\t\tname of the corporation to add\n"
734 << "\t\t--cash <cash>\t\t\tinitial corporation's cash (default: \"0\")\n\n";
735 std::cout << "\t--del-corp\t\t\t\tdelete an existing corporation\n";
737 std::cout << "\t\t--name <name>\t\t\tname of the corporation to delete\n\n";
738 std::cout << "\t--chg-corp\t\t\t\tchange an existing corporation\n";
740 std::cout << "\t\t--name <name>\t\t\tname of the corporation to change\n"
741 << "\t\t--add-cash <amount>[:<message>]\tadd cash to the corporation's account and optional comment message\n"
742 << "\t\t--set-cash <cash>[:<message>]\tnew corporation's cash and optional comment message\n\n";
747 std::cout << "sgconf, version: 2.0.0-alpha.\n";
750 } // namespace anonymous