docs: def init():
      '''
      Initializes git repo for nbinteract.
  
      1. Checks for requirements.txt or Dockerfile, offering to create a
         requirements.txt if needed.
      2. Sets the Binder spec using the `origin` git remote in .nbinteract.json.
      3. Prints a Binder URL so the user can debug their image if needed.
      '''
      log('Initializing folder for nbinteract.')
      log()
  
      log('Checking to see if this folder is the root folder of a git project.')
      if os.path.isdir('.git'):
          log("Looks like we're in the root of a git project.")
      else:
          error(
              "This folder doesn't look like the root of a git project. "
              "Please rerun nbinteract init in the top-level folder of a "
              "git project."
          )
          return ERROR
      log()
  
      log('Checking for requirements.txt or Dockerfile.')
      if os.path.isfile('Dockerfile'):
          log(
              'Dockerfile found. Note that Binder will use the Dockerfile '
              'instead of the requirements.txt file, so you should make sure '
              'your Dockerfile follows the format in {docker_docs}'
              .format(docker_docs=DOCKER_DOCS)
          )
      elif os.path.isfile('requirements.txt'):
          log('requirements.txt found.')
      else:
          log('No requirements.txt file found.')
          yes = yes_or_no(
              'Would you like to create a sample requirements.txt file?'
          )
          if yes:
              # TODO(sam): Don't hard-code requirements.txt
              with open('requirements.txt', 'w', encoding='utf-8') as f:
                  f.write(DEFAULT_REQUIREMENTS_TXT)
              log(
                  'Created requirements.txt. Edit this file now to include the '
                  'rest of your dependencies, then rerun nbinteract init.'
              )
              return SUCCESS
          else:
              log(
                  'Please manually create a requirements.txt file, then rerun '
                  'nbinteract init.'
              )
              return SUCCESS
      log()
  
      log('Generating .nbinteract.json file...')
      if os.path.isfile(CONFIG_FILE):
          log(
              ".nbinteract.json already exists, skipping generation. If you'd "
              "like to regenerate the file, remove .nbinteract.json and rerun "
              "this command."
          )
          log()
          log("Initialization success!")
          return SUCCESS
  
      try:
          github_origin = str(
              subprocess.check_output(
                  'git remote get-url origin',
                  stderr=subprocess.STDOUT,
                  shell=True
              ), 'utf-8'
          ).strip()
      except subprocess.CalledProcessError as e:
          error(
              "No git remote called origin found. Please set up your project's"
              "origin remote to point to a GitHub URL.\ngit error: {}".format(e)
          )
          return ERROR
  
      if 'github' not in github_origin:
          error(
              "Your project's origin remote {} doesn't look like a github "
              "URL. This may cause issues with Binder, so please double check "
              "your .nbinteract.json file after this script finishes. "
              "Continuing as planned..."
          )
  
      binder_spec = binder_spec_from_github_url(github_origin)
      with open(CONFIG_FILE, 'w', encoding='utf-8') as f:
          json.dump({'spec': binder_spec}, f, indent=4)
      log('Created .nbinteract.json file successfully')
      log()
  
      log(
          'Initialization complete! Now, you should make a git commit with the '
          'files created by in this process and push your commits to GitHub.'
      )
      log()
      log(
          'After you push, you should visit {} and verify that your Binder '
          'image successfully starts.'.format(BINDER_BASE_URL + binder_spec)
      )