def main()

in tools/add_module.py [0:0]


def main(argv=None):
  if argv is None:
    argv = sys.argv[1:]

  parser = argparse.ArgumentParser()
  parser.add_argument("--registry", type=str, default=".",
                      help="Specify the root path of the registry (default: the current working directory).")
  parser.add_argument(
      "--input", type=str, help="Take module information from a json file, which can be generated from previous input.")

  args = parser.parse_args(argv)

  if args.input:
    log(f"Getting module information from {args.input}...")
    module = Module()
    module.from_json(args.input)
  else:
    log("Getting module information from user input...")
    module = from_user_input()
    timestamp = time.strftime("%Y%m%d-%H%M%S")
    log(f"Saving module information to {module.name}.{timestamp}.json")
    log(f"You can use it via --input={module.name}.{timestamp}.json")
    module.dump(f"{module.name}.{timestamp}.json")

  client = RegistryClient(args.registry)

  if not client.contains(module.name):
    log(f"{module.name} is a new Bazel module...")
    homepage = ask_input(
        "Please enter the homepage url for this module: ").strip()
    maintainers = get_maintainers_from_input()
    client.init_module(module.name, maintainers, homepage)

  client.add(module, override=True)
  log(f"{module.name} {module.version} is added into the registry.")