blob: 676815d154edf55e8e49d2570fc4c410ac801e6a [file] [log] [blame]
Jiewen Tan870b29b2014-11-17 19:09:49 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Yumin Xia2c509c22017-02-09 14:37:36 -08002/*
Davide Pesaventod01c1a42019-01-21 21:42:45 -05003 * Copyright (c) 2014-2019, Regents of the University of California.
Jiewen Tan870b29b2014-11-17 19:09:49 -08004 *
5 * This file is part of NDNS (Named Data Networking Domain Name Service).
6 * See AUTHORS.md for complete list of NDNS authors and contributors.
7 *
8 * NDNS is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * NDNS, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
Jiewen Tan870b29b2014-11-17 19:09:49 -080020#include "logger.hpp"
Davide Pesaventod01c1a42019-01-21 21:42:45 -050021#include "ndns-label.hpp"
22#include "mgmt/management-tool.hpp"
23#include "util/util.hpp"
24
Jiewen Tan870b29b2014-11-17 19:09:49 -080025#include <boost/program_options.hpp>
26#include <boost/filesystem.hpp>
27#include <string>
28#include <iostream>
29
30int
31main(int argc, char* argv[])
32{
33 using std::string;
34 using namespace ndn;
Jiewen Tan870b29b2014-11-17 19:09:49 -080035
Jiewen Tan870b29b2014-11-17 19:09:49 -080036 string zoneStr;
Davide Pesaventod01c1a42019-01-21 21:42:45 -050037 string db = ndns::getDefaultDatabaseFile();
Jiewen Tan870b29b2014-11-17 19:09:49 -080038 try {
39 namespace po = boost::program_options;
40 po::variables_map vm;
41
42 po::options_description options("Generic Options");
43 options.add_options()
Davide Pesaventod01c1a42019-01-21 21:42:45 -050044 ("help,h", "print this help message and exit")
45 ("db,b", po::value<std::string>(&db)->default_value(db), "path to NDNS database file")
Jiewen Tan870b29b2014-11-17 19:09:49 -080046 ;
47
48 po::positional_options_description postion;
49 postion.add("zone", 1);
50
51 po::options_description cmdline_options;
52 cmdline_options.add(options);
53
54 po::parsed_options parsed =
55 po::command_line_parser(argc, argv).options(cmdline_options).positional(postion).run();
56
57 po::store(parsed, vm);
58 po::notify(vm);
59
60 if (vm.count("help")) {
61 std::cout << "Usage: ndns-list-all-zones [-b db]" << std::endl;
62 std::cout << options << std::endl;
63 return 0;
64 }
65 }
66 catch (const std::exception& ex) {
67 std::cerr << "Parameter Error: " << ex.what() << std::endl;
68 return 1;
69 }
70
71 try {
Yumin Xia2c509c22017-02-09 14:37:36 -080072 KeyChain keyChain;
Alexander Afanasyevd6b3bda2014-11-25 17:33:58 -080073 ndn::ndns::ManagementTool tool(db, keyChain);
Jiewen Tan870b29b2014-11-17 19:09:49 -080074 tool.listAllZones(std::cout);
75 }
76 catch (const std::exception& ex) {
77 std::cerr << "Error: " << ex.what() << std::endl;
78 return 1;
79 }
80}