summaryrefslogtreecommitdiff
path: root/nss-tool/nss_tool.cc
diff options
context:
space:
mode:
authorStefan Gschiel <stefan.gschiel.sg@gmail.com>2017-01-13 15:57:39 +0100
committerStefan Gschiel <stefan.gschiel.sg@gmail.com>2017-01-13 15:57:39 +0100
commitf054c1f78afe1a5f6463cadf4b0e186252453848 (patch)
tree3112b1a5c6f9dd637f1577fb47929b4011dc9ca8 /nss-tool/nss_tool.cc
parent555fccb2775b96911844b03ef97d13953623adab (diff)
downloadnss-hg-f054c1f78afe1a5f6463cadf4b0e186252453848.tar.gz
Bug 1330980 - Add first version of new "nss" tool r=ttaubert
Differential Revision: https://nss-review.dev.mozaws.net/D84
Diffstat (limited to 'nss-tool/nss_tool.cc')
-rw-r--r--nss-tool/nss_tool.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/nss-tool/nss_tool.cc b/nss-tool/nss_tool.cc
new file mode 100644
index 000000000..c857db132
--- /dev/null
+++ b/nss-tool/nss_tool.cc
@@ -0,0 +1,43 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <prinit.h>
+
+#include "argparse.h"
+#include "db/dbtool.h"
+
+static void Usage() {
+ std::cerr << "Usage: nss <command> <subcommand> [options]" << std::endl;
+ std::cerr << " nss db [--path <directory>] --list-certs" << std::endl;
+}
+
+int main(int argc, char **argv) {
+ if (argc < 2) {
+ Usage();
+ return 1;
+ }
+
+ if (std::string(argv[1]) != "db") {
+ Usage();
+ return 1;
+ }
+
+ int exit_code = 0;
+ PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
+
+ std::vector<std::string> arguments(argv + 2, argv + argc);
+ DBTool tool;
+ if (!tool.Run(arguments)) {
+ tool.Usage();
+ exit_code = 1;
+ }
+
+ PR_Cleanup();
+
+ return exit_code;
+}