import os import sys import toml from rich import print if 'XDG_CONFIG_HOME' in os.environ: config_dir = os.environ['XDG_CONFIG_HOME'] else: config_dir = os.path.join(os.environ['HOME'], '.config') # if the config dir doesn't exist, create it config_dir = os.path.join(config_dir, 'vacuum-tube') os.makedirs(config_dir, exist_ok=True) # create an example config file if it doesn't already exist if not os.path.exists(config_dir + '/config.toml'): with open(config_dir + '/config.toml', 'a+') as f: f.write('''# Disable ascii art if you're using a screen reader or want smaller output ascii_art = true # Change the output color # Example: `red`, `#553e78` or `rgb(104,74,112)` color = "#d89961" [repo] # Example: `~/backups/backup.borg` or `ssh://agatha@some.place:22/~/backups/backup.borg` path = "" # Leave empty if none # If repo is encrypted and no passphrase is provided, the program will ask you for one. passphrase = "" [disk] # Example: `/dev/sda1` partition = "" # If the backup disk is remote, provide an ssh command. # Otherwise, leave empty. # Example: `ssh -p 22 agatha@some.place` ssh = ""''') print('No existing configuration found, creating one at: [underline #d89961]' + config_dir + '/config.toml') sys.exit() config = toml.load(config_dir + '/config.toml')