mirror of
https://github.com/hughrun/ephemetoot
synced 2025-02-17 04:00:35 +01:00
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"
|
"--archive-deleted", action="store_true", help="Only archive toots that are being deleted"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
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(
|
parser.add_argument(
|
||||||
"--datestamp", action="store_true", help="Include a datetime stamp for every action (e.g. deleting a toot)"
|
"--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"
|
"--hide-skipped", "--hide_skipped", action="store_true", help="Do not write to log when skipping saved toots"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
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(
|
parser.add_argument(
|
||||||
"--pace", action="store_true", help="Slow deletion actions to match API rate limit to avoid pausing"
|
"--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"
|
"--time", action="store", metavar=('hour', 'minute'), nargs="*", help="Hour and minute to schedule: e.g. 9 30 for 9.30am"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
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()
|
options = parser.parse_args()
|
||||||
@ -85,6 +85,8 @@ else:
|
|||||||
config_file = os.path.join( os.getcwd(), options.config )
|
config_file = os.path.join( os.getcwd(), options.config )
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
try:
|
||||||
|
|
||||||
if options.init:
|
if options.init:
|
||||||
func.init()
|
func.init()
|
||||||
elif options.version:
|
elif options.version:
|
||||||
@ -105,5 +107,9 @@ def main():
|
|||||||
for user in accounts:
|
for user in accounts:
|
||||||
func.checkToots(user, options)
|
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__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
x
Reference in New Issue
Block a user