docs: def main(args):
    """Launch the appropriate builder."""
  
    grr_config.CONFIG.AddContext(contexts.CLIENT_BUILD_CONTEXT)
  
    if args.subparser_name == "generate_client_config":
      # We don't need a full init to just build a config.
      GetClientConfig(args.client_config_output)
      return
  
    # TODO(user): Find out if adding the client-builder context is still
    # necessary.
    context = FLAGS.context
    context.append(contexts.CLIENT_BUILD_CONTEXT)
  
    config_lib.SetPlatformArchContext()
    config_lib.ParseConfigCommandLine()
  
    # Use basic console output logging so we can see what is happening.
    logger = logging.getLogger()
    handler = logging.StreamHandler()
    handler.setLevel(logging.DEBUG if FLAGS.verbose else logging.INFO)
    logger.handlers = [handler]
  
    if args.subparser_name == "build":
      if grr_config.CONFIG["Client.fleetspeak_enabled"]:
        if grr_config.CONFIG.ContextApplied("Platform:Darwin"):
          if not args.fleetspeak_service_config:
            raise RuntimeError("--fleetspeak_service_config must be provided.")
          if not grr_config.CONFIG.Get("ClientBuilder.install_dir"):
            raise RuntimeError("ClientBuilder.install_dir must be set.")
          if not grr_config.CONFIG.Get("ClientBuilder.fleetspeak_plist_path"):
            raise RuntimeError("ClientBuilder.fleetspeak_plist_path must be set.")
        grr_config.CONFIG.Set("ClientBuilder.client_path",
                              "grr_response_client.grr_fs_client")
      TemplateBuilder().BuildTemplate(
          context=context,
          output=args.output,
          fleetspeak_service_config=args.fleetspeak_service_config)
    elif args.subparser_name == "repack":
      if args.debug_build:
        context.append("DebugClientBuild Context")
      result_path = repacking.TemplateRepacker().RepackTemplate(
          args.template,
          args.output_dir,
          context=context,
          sign=args.sign,
          signed_template=args.signed_template)
  
      if not result_path:
        raise ErrorDuringRepacking(" ".join(sys.argv[:]))
    elif args.subparser_name == "repack_multiple":
  
      # Resolve globs manually on Windows.
      templates = []
      for template in args.templates:
        if "*" in template:
          templates.extend(glob.glob(template))
        else:
          # This could go through glob but then we'd swallow errors for
          # non existing files.
          templates.append(template)
  
      repack_configs = []
      for repack_config in args.repack_configs:
        if "*" in repack_config:
          repack_configs.extend(glob.glob(repack_config))
        else:
          # This could go through glob but then we'd swallow errors for
          # non existing files.
          repack_configs.append(repack_config)
  
      MultiTemplateRepacker().RepackTemplates(
          repack_configs,
          templates,
          args.output_dir,
          config=FLAGS.config,
          sign=args.sign,
          signed_template=args.signed_template)
    elif args.subparser_name == "sign_template":
      repacking.TemplateRepacker().SignTemplate(
          args.template, args.output_file, context=context)
      if not os.path.exists(args.output_file):
        raise RuntimeError("Signing failed: output not written")