]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
9f95a23c | 14 | #include <iostream> |
7c673cae | 15 | |
9f95a23c TL |
16 | #include <boost/program_options/cmdline.hpp> |
17 | #include <boost/program_options/option.hpp> | |
18 | #include <boost/program_options/options_description.hpp> | |
19 | #include <boost/program_options/parsers.hpp> | |
20 | #include <boost/program_options/variables_map.hpp> | |
7c673cae | 21 | |
7c673cae | 22 | #include "include/rados/librados.h" |
9f95a23c | 23 | #include "ceph_ver.h" |
7c673cae | 24 | |
9f95a23c | 25 | namespace po = boost::program_options; |
7c673cae FG |
26 | |
27 | int main(int argc, const char **argv) | |
28 | { | |
9f95a23c TL |
29 | po::options_description desc{"usage: librados-config [option]"}; |
30 | desc.add_options() | |
31 | ("help,h", "print this help message") | |
32 | ("version", "library version") | |
33 | ("vernum", "library version code") | |
34 | ("release", "print release name"); | |
35 | ||
36 | po::parsed_options parsed = | |
37 | po::command_line_parser(argc, argv).options(desc).run(); | |
38 | po::variables_map vm; | |
39 | po::store(parsed, vm); | |
40 | po::notify(vm); | |
41 | ||
42 | if (vm.count("help")) { | |
43 | std::cout << desc << std::endl; | |
44 | } else if (vm.count("version")) { | |
7c673cae FG |
45 | int maj, min, ext; |
46 | rados_version(&maj, &min, &ext); | |
9f95a23c TL |
47 | std::cout << maj << "." << min << "." << ext << std::endl; |
48 | } else if (vm.count("vernum")) { | |
49 | std::cout << std::hex << LIBRADOS_VERSION_CODE << std::dec << std::endl; | |
50 | } else if (vm.count("release")) { | |
51 | std::cout << CEPH_RELEASE_NAME << ' ' | |
52 | << '(' << CEPH_RELEASE_TYPE << ')' | |
53 | << std::endl; | |
54 | } else { | |
55 | std::cerr << argv[0] << ": -h or --help for usage" << std::endl; | |
56 | return 1; | |
7c673cae | 57 | } |
7c673cae FG |
58 | } |
59 |