add try/except for missing config file
This commit is contained in:
parent
275f16e997
commit
beac59d440
|
@ -43,7 +43,7 @@ parser.add_argument(
|
|||
"--archive-deleted", action="store_true", help="Only archive toots that are being deleted"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--config", action="store", metavar="filepath", default="config.yaml", help="Filepath of your config file, absolute or relative to the current directory. If no --config path is provided, ephemetoot will use 'config.yaml'."
|
||||
"--config", action="store", metavar="filepath", default="config.yaml", help="Filepath of your config file, absolute or relative to the current directory. If no --config path is provided, ephemetoot will use 'config.yaml'in the current directory"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--datestamp", action="store_true", help="Include a datetime stamp for every action (e.g. deleting a toot)"
|
||||
|
@ -52,7 +52,7 @@ parser.add_argument(
|
|||
"--hide-skipped", "--hide_skipped", action="store_true", help="Do not write to log when skipping saved toots"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--init", action="store_true", help="Initialise creation of a config file saved in the current directory."
|
||||
"--init", action="store_true", help="Create a config file that is saved in the current directory"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--pace", action="store_true", help="Slow deletion actions to match API rate limit to avoid pausing"
|
||||
|
@ -73,7 +73,7 @@ parser.add_argument(
|
|||
"--time", action="store", metavar=('hour', 'minute'), nargs="*", help="Hour and minute to schedule: e.g. 9 30 for 9.30am"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version", action="store_true", help="Display the version number"
|
||||
"--version", action="store_true", help="Display the version numbers of the installed and latest versions"
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
@ -85,6 +85,8 @@ else:
|
|||
config_file = os.path.join( os.getcwd(), options.config )
|
||||
|
||||
def main():
|
||||
try:
|
||||
|
||||
if options.init:
|
||||
func.init()
|
||||
elif options.version:
|
||||
|
@ -105,5 +107,9 @@ def main():
|
|||
for user in accounts:
|
||||
func.checkToots(user, options)
|
||||
|
||||
except FileNotFoundError as err:
|
||||
print("🕵️ Missing config file")
|
||||
print("Run \033[92mephemetoot --init\033[0m to create a new one\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue