]> git.proxmox.com Git - ceph.git/blob - ceph/src/librados-config.cc
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librados-config.cc
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 */
14 #include <iostream>
15
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>
21
22 #include "include/rados/librados.h"
23 #include "ceph_ver.h"
24
25 namespace po = boost::program_options;
26
27 int main(int argc, const char **argv)
28 {
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")) {
45 int maj, min, ext;
46 rados_version(&maj, &min, &ext);
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;
57 }
58 }
59