susumu.yata
null+****@clear*****
Fri Dec 14 17:40:14 JST 2012
susumu.yata 2012-12-14 17:40:14 +0900 (Fri, 14 Dec 2012) New Revision: a8b60ba950e7d6bf369ce5b9e86ee840ee8fc02a https://github.com/groonga/grnxx/commit/a8b60ba950e7d6bf369ce5b9e86ee840ee8fc02a Log: Add a comman line tool "grnxx". Only "grnxx --version" is available. Added files: src/Makefile.am src/grnxx.cpp Modified files: .gitignore Makefile.am configure.ac Modified: .gitignore (+1 -0) =================================================================== --- .gitignore 2012-12-14 16:53:06 +0900 (b01d006) +++ .gitignore 2012-12-14 17:40:14 +0900 (fdfc92a) @@ -24,6 +24,7 @@ lib/version.h libtool ltmain.sh missing +src/grnxx stamp-h1 temp/ test/test_alpha_blob_vector Modified: Makefile.am (+1 -1) =================================================================== --- Makefile.am 2012-12-14 16:53:06 +0900 (926881d) +++ Makefile.am 2012-12-14 17:40:14 +0900 (336eec2) @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = lib test +SUBDIRS = lib src test EXTRA_DIST = \ COPYING-GPL-3.0 \ Modified: configure.ac (+1 -0) =================================================================== --- configure.ac 2012-12-14 16:53:06 +0900 (01ec0f6) +++ configure.ac 2012-12-14 17:40:14 +0900 (72c7057) @@ -43,6 +43,7 @@ AC_CONFIG_FILES([Makefile lib/alpha/Makefile lib/db/Makefile lib/io/Makefile + src/Makefile test/Makefile]) AC_OUTPUT Added: src/Makefile.am (+6 -0) 100644 =================================================================== --- /dev/null +++ src/Makefile.am 2012-12-14 17:40:14 +0900 (0630b73) @@ -0,0 +1,6 @@ +AM_CXXFLAGS = -I$(top_srcdir)/lib + +bin_PROGRAMS = grnxx + +grnxx_SOURCES = grnxx.cpp +grnxx_LDADD = ../lib/libgrnxx.la Added: src/grnxx.cpp (+48 -0) 100644 =================================================================== --- /dev/null +++ src/grnxx.cpp 2012-12-14 17:40:14 +0900 (9d66b5f) @@ -0,0 +1,48 @@ +// FIXME +#include <getopt.h> + +#include <iostream> + +#include "grnxx.hpp" + +namespace { + +void print_version() { + std::cout << "grnxx " << grnxx::Grnxx::version() << std::endl; +} + +void print_usage() { + std::cout << "Usage: grnxx [options...]\n\n" + << "Options:\n" + << " -h, --help: show usage\n" + << " -v, --version: show grnxx version" + << std::endl; +} + +} // namespace + +int main(int argc, char *argv[]) { + const struct option long_options[] = { + { "help", 0, nullptr, 'h' }, + { "version", 0, nullptr, 'v' }, + { nullptr, 0, nullptr, 0 } + }; + int value; + while ((value = ::getopt_long(argc, argv, "hv", + long_options, nullptr)) != -1) { + switch (value) { + case 'h': { + print_usage(); + break; + } + case 'v': { + print_version(); + return 0; + } + default: { + break; + } + } + } + return 0; +} -------------- next part -------------- HTML����������������������������...Download