docs: def configure(args, parser):
      """
      Color guide
  
      - red: Error and warning messages
      - green: Welcome messages (use sparingly)
      - blue: Default values
      - bold_magenta: Action items
      - bold_black: Parts of code to be run or copied that should be modified
      """
      if not args.force and on_travis():
          parser.error(red("doctr appears to be running on Travis. Use "
              "doctr configure --force to run anyway."))
  
      if not args.authenticate:
          args.upload_key = False
  
      if args.travis_tld:
          if args.travis_tld in ['c', 'com', '.com', 'travis-ci.com']:
              args.travis_tld = 'travis-ci.com'
          else:
              args.travis_tld = 'travis-ci.org'
  
      print(green(dedent("""\
      Welcome to Doctr.
  
      We need to ask you a few questions to get you on your way to automatically
      deploying from Travis CI to GitHub pages.
      """)))
  
      login_kwargs = {}
  
      if args.authenticate:
          while not login_kwargs:
              try:
                  login_kwargs = GitHub_login()
              except AuthenticationFailed as e:
                  print(red(e))
      else:
          login_kwargs = {'auth': None, 'headers': None}
  
      GitHub_token = None
      get_build_repo = False
      default_repo = guess_github_repo()
      while not get_build_repo:
          try:
              if default_repo:
                  build_repo = input("What repo do you want to build the docs for? [{default_repo}] ".format(default_repo=blue(default_repo)))
                  if not build_repo:
                      build_repo = default_repo
              else:
                  build_repo = input("What repo do you want to build the docs for (org/reponame, like 'drdoctr/doctr')? ")
  
              is_private = check_repo_exists(build_repo, service='github',
                                                 **login_kwargs)['private']
              if is_private and not args.authenticate:
                  sys.exit(red("--no-authenticate is not supported for private repositories."))
  
              headers = {}
              travis_token = None
              if is_private:
                  if args.token:
                      GitHub_token = generate_GitHub_token(note="Doctr token for pushing to gh-pages from Travis (for {build_repo}).".format(build_repo=build_repo),
                                                           scopes=["read:org", "user:email", "repo"], **login_kwargs)['token']
                  travis_token = get_travis_token(GitHub_token=GitHub_token, **login_kwargs)
                  headers['Authorization'] = "token {}".format(travis_token)
  
              service = args.travis_tld if args.travis_tld else 'travis'
              c = check_repo_exists(build_repo, service=service, ask=True, headers=headers)
              tld = c['service'][-4:]
              is_private = c['private'] or is_private
              if is_private and not args.authenticate:
                  sys.exit(red("--no-authenticate is not supported for private repos."))
  
              get_build_repo = True
          except GitHubError:
              raise
          except RuntimeError as e:
              print(red('\n{!s:-^{}}\n'.format(e, 70)))
  
      get_deploy_repo = False
      while not get_deploy_repo:
          try:
              deploy_repo = input("What repo do you want to deploy the docs to? [{build_repo}] ".format(build_repo=blue(build_repo)))
              if not deploy_repo:
                  deploy_repo = build_repo
  
              if deploy_repo != build_repo:
                  check_repo_exists(deploy_repo, service='github', **login_kwargs)
  
              get_deploy_repo = True
          except GitHubError:
              raise
          except RuntimeError as e:
              print(red('\n{!s:-^{}}\n'.format(e, 70)))
  
      N = IncrementingInt(1)
  
      header = green("\n================== You should now do the following ==================\n")
  
      if args.token:
          if not GitHub_token:
              GitHub_token = generate_GitHub_token(**login_kwargs)['token']
          encrypted_variable = encrypt_variable("GH_TOKEN={GitHub_token}".format(GitHub_token=GitHub_token).encode('utf-8'),
                                                build_repo=build_repo, tld=tld, travis_token=travis_token, **login_kwargs)
          print(dedent("""
          A personal access token for doctr has been created.
  
          You can go to https://github.com/settings/tokens to revoke it."""))
  
          print(header)
      else:
          deploy_key_repo, env_name, keypath = get_deploy_key_repo(deploy_repo, args.key_path)
  
          private_ssh_key, public_ssh_key = generate_ssh_key()
          key = encrypt_to_file(private_ssh_key, keypath + '.enc')
          del private_ssh_key # Prevent accidental use below
          public_ssh_key = public_ssh_key.decode('ASCII')
          encrypted_variable = encrypt_variable(env_name.encode('utf-8') + b"=" + key,
                                                build_repo=build_repo, tld=tld, travis_token=travis_token, **login_kwargs)
  
          deploy_keys_url = 'https://github.com/{deploy_repo}/settings/keys'.format(deploy_repo=deploy_key_repo)
  
          if args.upload_key:
  
              upload_GitHub_deploy_key(deploy_key_repo, public_ssh_key, **login_kwargs)
  
              print(dedent("""
              The deploy key has been added for {deploy_repo}.
  
              You can go to {deploy_keys_url} to revoke the deploy key.\
              """.format(deploy_repo=deploy_key_repo, deploy_keys_url=deploy_keys_url, keypath=keypath)))
              print(header)
          else:
              print(header)
              print(dedent("""\
              {N}. {BOLD_MAGENTA}Go to {deploy_keys_url}
                 and add the following as a new key:{RESET}
  
                  {ssh_key}
                 {BOLD_MAGENTA}Be sure to allow write access for the key.{RESET}
              """.format(ssh_key=public_ssh_key, deploy_keys_url=deploy_keys_url, N=N,
                         BOLD_MAGENTA=BOLD_MAGENTA, RESET=RESET)))
  
  
          print(dedent("""\
          {N}. {BOLD_MAGENTA}Add the file {keypath}.enc to be staged for commit:{RESET}
  
              git add {keypath}.enc
          """.format(keypath=keypath, N=N, BOLD_MAGENTA=BOLD_MAGENTA, RESET=RESET)))
  
      options = '--built-docs ' + bold_black('<path/to/built/html/>')
      if args.key_path:
          options += ' --key-path {keypath}.enc'.format(keypath=keypath)
      if deploy_repo != build_repo:
          options += ' --deploy-repo {deploy_repo}'.format(deploy_repo=deploy_repo)
  
      key_type = "deploy key"
      if args.token:
          options += ' --token'
          key_type = "personal access token"
  
      print(dedent("""\
      {N}. {BOLD_MAGENTA}Add these lines to your `.travis.yml` file:{RESET}
  
          env:
            global:
              # Doctr {key_type} for {deploy_repo}
              - secure: "{encrypted_variable}"
  
          script:
            - set -e
            - {BOLD_BLACK}<Command to build your docs>{RESET}
            - pip install doctr
            - doctr deploy {options} {BOLD_BLACK}<target-directory>{RESET}
      """.format(options=options, N=N, key_type=key_type,
          encrypted_variable=encrypted_variable.decode('utf-8'),
          deploy_repo=deploy_repo, BOLD_MAGENTA=BOLD_MAGENTA,
          BOLD_BLACK=BOLD_BLACK, RESET=RESET)))
  
      print(dedent("""\
      Replace the text in {BOLD_BLACK}<angle brackets>{RESET} with the relevant
      things for your repository.
      """.format(BOLD_BLACK=BOLD_BLACK, RESET=RESET)))
  
      print(dedent("""\
      Note: the `set -e` prevents doctr from running when the docs build fails.
      We put this code under `script:` so that if doctr fails it causes the
      build to fail.
      """))
  
      print(dedent("""\
      {N}. {BOLD_MAGENTA}Commit and push these changes to your GitHub repository.{RESET}
         The docs should now build automatically on Travis.
      """.format(N=N, BOLD_MAGENTA=BOLD_MAGENTA, RESET=RESET)))
  
      print("See the documentation at https://drdoctr.github.io/ for more information.")