This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Bebop/bebop/__main__.py
dece 3a818812a9 config: add config management
A config file is now created and used, and a few hardcoded things in the
source have been moved to the config file \o/
2021-04-18 14:17:20 +02:00

35 lines
884 B
Python

import argparse
from bebop.browser.browser import Browser
from bebop.config import load_config
from bebop.fs import get_config_path, get_user_data_path
from bebop.tofu import load_cert_stash, save_cert_stash
def main():
argparser = argparse.ArgumentParser()
argparser.add_argument("url", nargs="?", default=None)
args = argparser.parse_args()
if args.url:
start_url = args.url
else:
start_url = None
config_path = get_config_path()
config = load_config(config_path)
user_data_path = get_user_data_path()
if not user_data_path.exists():
user_data_path.mkdir()
cert_stash_path = user_data_path / "known_hosts.txt"
cert_stash = load_cert_stash(cert_stash_path) or {}
try:
Browser(config, cert_stash).run(start_url=start_url)
finally:
save_cert_stash(cert_stash, cert_stash_path)
main()