prompt for paths

This commit is contained in:
Sierra 2020-10-22 15:48:37 -04:00
parent ecbe06b61c
commit 2e66d7f40c
1 changed files with 8 additions and 4 deletions

View File

@ -19,7 +19,11 @@ def gen_masto_obj(config_data: dict) -> Mastodon:
# generate phlog URLs for linking in the post
def gen_url(config_data: dict, phlog_file: str) -> dict:
base_path = f"{config_data['gopher']}/{config_data['phlog_format']}/{phlog_file}"
base_path = ''
if phlog_file == '':
base_path = f"{config_data['gopher']}"
else:
base_path = f"{config_data['gopher']}/{config_data['phlog_format']}/{phlog_file}"
gopher_url = f"gopher://{base_path}"
proxy_url = f"https://{config_data['proxy']}/{base_path}"
urls = {'gopher':gopher_url, 'proxy':proxy_url}
@ -31,7 +35,7 @@ def post_check(post: str) -> bool:
print()
print(post)
print()
will_continue = input("Continue? [y/N] ")
will_continue = input('Continue? [y/N] ')
print()
return will_continue.upper() in ['Y', 'YES']
@ -43,12 +47,12 @@ def main():
# generate URLs
# TODO: prompt for phlog path
phlog_file = 'test.txt'
phlog_file = input('Post location (leave blank for root): ')
urls = gen_url(config_data, phlog_file)
# get post description, generate post text
# TODO: Spawn $EDITOR, content warnings
text = "Test post, please ignore"
text = 'Test post, please ignore'
post = f"{text}\n\nGopher: {urls['gopher']}\nHTML Proxy: {urls['proxy']}"
# verify the post with the user and post it