# HG changeset patch # User David Demelier # Date 1562782500 -7200 # Node ID 800b025f98426a56ec5fc6b20e05bd75c56d3c3c # Parent a23b7b574ed2c94fe8d0ca038d1930bb4002e4a0 irccd: add info and version, closes #1672 diff -r a23b7b574ed2 -r 800b025f9842 CHANGES.md --- a/CHANGES.md Wed Jul 10 20:10:00 2019 +0200 +++ b/CHANGES.md Wed Jul 10 20:15:00 2019 +0200 @@ -15,7 +15,8 @@ - The origin in rule is now first class value (#947), - New option `ipv4` in `[transport]` (#945), - New option `ipv4` in `[server]` (#945), -- Section `[format]` is renamed to `[templates]` (#1671). +- Section `[format]` is renamed to `[templates]` (#1671), +- New commands are available as irccd arguments `info` and `version` (#1672). irccdctl: diff -r a23b7b574ed2 -r 800b025f9842 irccd/main.cpp --- a/irccd/main.cpp Wed Jul 10 20:10:00 2019 +0200 +++ b/irccd/main.cpp Wed Jul 10 20:15:00 2019 +0200 @@ -49,39 +49,46 @@ void usage() { - std::cerr << "usage: irccd [options...]\n\n"; + std::cerr << "usage: irccd [options...]\n"; + std::cerr << " irccd info\n"; + std::cerr << " irccd version\n\n"; std::cerr << "Available options:\n"; std::cerr << " -c, --config file specify the configuration file\n"; std::cerr << " -h, --help show this help\n"; std::cerr << " -v, --verbose be verbose\n"; - std::cerr << " --version show the version\n"; std::exit(1); } // }}} +// {{{ info + +void info() +{ + bool ssl = false; + bool js = false; + +#if defined(IRCCD_HAVE_SSL) + ssl = true; +#endif +#if defined(IRCCD_HAVE_JS) + js = true; +#endif + + std::cout << std::boolalpha; + std::cout << "ssl: " << ssl << std::endl; + std::cout << "javascript: " << js << std::endl; + + std::exit(0); +} + +// }}} + // {{{ version -void version(const option::result& options) +void version() { std::cout << IRCCD_VERSION << std::endl; - - if (options.count("-v") > 0 || options.count("--verbose") > 0) { - bool ssl = false; - bool js = false; - -#if defined(IRCCD_HAVE_SSL) - ssl = true; -#endif -#if defined(IRCCD_HAVE_JS) - js = true; -#endif - - std::cout << std::boolalpha << std::endl; - std::cout << "ssl: " << ssl << std::endl; - std::cout << "javascript: " << js << std::endl; - } - std::exit(0); } @@ -117,7 +124,6 @@ { "--help", false }, { "-v", false }, { "--verbose", false }, - { "--version", false } }; result = option::read(argc, argv, options); @@ -126,9 +132,6 @@ if (pair.first == "-h" || pair.first == "--help") usage(); // NOTREACHED - if (pair.first == "--version") - version(result); - // NOTREACHED if (pair.first == "-v" || pair.first == "--verbose") instance->get_log().set_verbose(true); } @@ -195,6 +198,16 @@ const auto options = parse(argc, argv); + if (argc > 0) { + if (std::strcmp(argv[0], "info") == 0) + irccd::daemon::info(); + // NOTREACHED + if (std::strcmp(argv[0], "version") == 0) + irccd::daemon::version(); + // NOTREACHED + } + + try { instance->set_config(open(options)); instance->load();