Skip to content

Commit

Permalink
fix: config.gist to config.github in syncshell/cli.py
Browse files Browse the repository at this point in the history
  • Loading branch information
msudgh committed Apr 27, 2024
1 parent 5eeedb6 commit 99a7629
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions syncshell/cli.py
Expand Up @@ -43,14 +43,14 @@ def auth(self):
config.parser["Auth"]["token"] = str(prompt_token)

# Set new token key
config.gist = Github(config.parser["Auth"]["token"])
config.github = Github(config.parser["Auth"]["token"])

spinner = Spinner.NewTask("Check authentication...")

# Write config file if Github user already authorized
if config.is_logged_in():
spinner.succeed("Your Github token key is authenticated.")
config.write()
config.save_config()
else:
spinner.fail("Your Github token key is not valid.")
sys.exit(1)
Expand All @@ -68,11 +68,11 @@ def upload(self):

try:
if config.parser["Auth"]["gist_id"]:
gist = config.gist.get_gist(config.parser["Auth"]["gist_id"])
gist = config.github.get_gist(config.parser["Auth"]["gist_id"])

# Set upload date
config.parser["Upload"]["last_date"] = str(int(time.time()))
config.write()
config.save_config()

files = self.__prepare_payload()

Expand All @@ -82,15 +82,15 @@ def upload(self):
else:
description = "SyncShell Gist"

user = config.gist.get_user()
user = config.github.get_user()
files = self.__prepare_payload()
gist = user.create_gist(False, files, description)

# Set upload date
config.parser["Upload"]["last_date"] = str(int(time.time()))
config.parser["Auth"]["gist_id"] = gist.id

config.write()
config.save_config()

files = self.__prepare_payload()
gist.edit(files=files)
Expand All @@ -110,7 +110,7 @@ def upload(self):
)

config.parser["Auth"]["gist_id"] = ""
config.write()
config.save_config()
sys.exit(1)

def download(self):
Expand All @@ -123,14 +123,14 @@ def download(self):
spinner = Spinner.NewTask("Downloading ...")

# Redefine Github instance with new token
config.gist = Github(token)
config.github = Github(token)

# Exit process if not logged in
if not config.is_logged_in():
sys.exit(1)

# Download Gist object
gist = config.gist.get_gist(gist_id)
gist = config.github.get_gist(gist_id)

if len(gist.files) != 2:
spinner.fail("Gist content corrupted, Please use another Gist.")
Expand All @@ -145,10 +145,9 @@ def download(self):
spinner.fail("Unable to convert different shells")
sys.exit(1)

# Write configuration
config.parser["Auth"]["token"] = token
config.parser["Auth"]["gist_id"] = gist_id
config.write()
config.save_config()

history_file = config.get_shell_history()
history_content = history_file["content"]
Expand Down

0 comments on commit 99a7629

Please sign in to comment.