nss-tool/nss_tool.cc
author Franziskus Kiefer <franziskuskiefer@gmail.com>
Tue, 24 Jan 2017 12:15:13 +0100
changeset 13052 de147409a6828946a35738ba12ca0fc2f4c41b54
parent 13027 3e75c6ad7f8ddd997a025033a9ea378696dd87b7
child 13089 f7807b2c33820cf560a19293eaa71738a379eb48
permissions -rw-r--r--
Bug 1177759 - make clang version detection robust for higher versions, r=ttaubert Differential Revision: https://nss-review.dev.mozaws.net/D171

/* 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;
}