text: """
  syntax: "token"
  syntax_description: ""
  ---
  GitHubトークンを設定します。
  """
  
  import sys
  from colorama import Fore, Style  # , Back
  import requests
  import stdiomask
  
  
  def set_token():
      print(
          f"{Fore.LIGHTBLACK_EX}{Style.BRIGHT}https://docs.github.com/ja/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token {Style.NORMAL}を参考にトークンを取得して下さい。{Fore.RESET}"
      )
      token = stdiomask.getpass(Fore.LIGHTBLACK_EX + "トークン: " + Fore.RESET)
      print(Fore.YELLOW + "認証しています..." + Fore.RESET)
      resp = requests.get(
          "https://api.github.com/user",
          headers={"authorization": "token " + token},
      )
      if resp.status_code != 200:
          print(Fore.RED + "認証に失敗しました。もう一度試してみて下さい。" + Fore.RESET)
          sys.exit(1)
      user_login_id = resp.json()["login"]
      name = resp.json()["name"] or user_login_id
      print(f"{Fore.GREEN}{Style.BRIGHT}{name}({user_login_id}){Style.NORMAL} として認証しました。{Fore.RESET}")
      with open("./savedata/github-token", "w") as f:
          f.write(token)
      return token
  
  
  def main():
      set_token()
  