diff --git a/README.md b/README.md index e5516b5c..cde23453 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Contents * [What can I back up?](#what-can-i-back-up) * [Backup Customization](#backup-customization) * [Output Structure](#output-structure) + * [Reinstallation](#reinstallation) * [Inspiration](#inspiration) * [Want to contribute?](#want-to-contribute) @@ -46,6 +47,7 @@ Usage: shallow-backup [OPTIONS] Written by Aaron Lichtman (@alichtman). Options: + --add_dot Add a dotfile or dotfolder to config by path. -all Full back up. -configs Back up app config files. -delete_config Delete config file. @@ -195,6 +197,10 @@ backup_dir/ └── sublime3_list.txt ``` +### Reinstallation + +To reinstall your dotfiles, clone your dotfiles repo and make sure your shallow-backup config path can be found at either `~/.config/shallow-backup.conf` or `$XDG_CONFIG_HOME/.shallow_backup.conf`. Set the `backup-path` key in the config to the path of your cloned dotfiles. Then run `$ shallow-backup -reinstall_dots`. + ### Inspiration --- diff --git a/shallow_backup/__main__.py b/shallow_backup/__main__.py index 12bb212d..be5e3698 100644 --- a/shallow_backup/__main__.py +++ b/shallow_backup/__main__.py @@ -12,7 +12,7 @@ # custom help options @click.command(context_settings=dict(help_option_names=['-h', '-help', '--help'])) -@click.option('--add', default=None, help="Add a dotfile or dotfolder by path.") +@click.option('--add_dot', default=None, help="Add a dotfile or dotfolder to config by path.") @click.option('-all', is_flag=True, default=False, help="Full back up.") @click.option('-configs', is_flag=True, default=False, help="Back up app config files.") @click.option('-delete_config', is_flag=True, default=False, help="Delete config file.") @@ -32,7 +32,7 @@ @click.option('-separate_dotfiles_repo', is_flag=True, default=False, help="Use if you are trying to maintain a separate dotfiles repo and running into issue #229.") @click.option('-show', is_flag=True, default=False, help="Display config file.") @click.option('--version', '-v', is_flag=True, default=False, help='Display version and author info.') -def cli(add, all, configs, delete_config, destroy_backup, dotfiles, fonts, new_path, +def cli(add_dot, all, configs, delete_config, destroy_backup, dotfiles, fonts, new_path, no_splash, old_path, packages, reinstall_all, reinstall_configs, reinstall_dots, reinstall_fonts, reinstall_packages, remote, separate_dotfiles_repo, show, version): @@ -46,7 +46,7 @@ def cli(add, all, configs, delete_config, destroy_backup, dotfiles, fonts, new_p upgrade_from_pre_v3() # Process CLI args - admin_action = any([add, delete_config, destroy_backup, show, version]) + admin_action = any([add_dot, delete_config, destroy_backup, show, version]) has_cli_arg = any([old_path, all, dotfiles, packages, fonts, configs, reinstall_dots, reinstall_fonts, reinstall_all, reinstall_configs, reinstall_packages]) @@ -67,8 +67,8 @@ def cli(add, all, configs, delete_config, destroy_backup, dotfiles, fonts, new_p destroy_backup_dir(backup_home_path) elif show: show_config() - elif add: - new_config = add_path(backup_config, add) + elif add_dot: + new_config = add_dot_path_to_config(backup_config, add_dot) write_config(new_config) sys.exit() diff --git a/shallow_backup/config.py b/shallow_backup/config.py index 5bf04a5d..59c68bc8 100644 --- a/shallow_backup/config.py +++ b/shallow_backup/config.py @@ -111,7 +111,7 @@ def delete_config_file(): print_red_bold("ERROR: No config file found.") -def add_path(backup_config: dict, filePath: str) -> dict: +def add_dot_path_to_config(backup_config: dict, file_path: str) -> dict: """ Add a path to the config under the correct heading (dotfiles / dotfolders). Exits if the filepath parameter is invalid. @@ -125,14 +125,14 @@ def strip_home(full_path): """ return full_path[len(os.path.expanduser("~")) + 1:] - absPath = path.abspath(filePath) - if not path.exists(absPath): - print_path_red("Invalid file path:", absPath) + abs_path = path.abspath(file_path) + if not path.exists(abs_path): + print_path_red("Invalid file path:", abs_path) sys.exit(1) - elif path.isdir(absPath): - backup_config["dotfolders"] += [strip_home(absPath)] + elif path.isdir(abs_path): + backup_config["dotfolders"] += [strip_home(abs_path)] else: # Otherwise it's a dotfile - backup_config["dotfiles"] += [strip_home(absPath)] + backup_config["dotfiles"] += [strip_home(abs_path)] return backup_config diff --git a/shallow_backup/constants.py b/shallow_backup/constants.py index 47f52d47..4628af3a 100644 --- a/shallow_backup/constants.py +++ b/shallow_backup/constants.py @@ -1,6 +1,6 @@ class ProjInfo: PROJECT_NAME = 'shallow-backup' - VERSION = '3.2' + VERSION = '3.3' AUTHOR_GITHUB = 'alichtman' AUTHOR_FULL_NAME = 'Aaron Lichtman' DESCRIPTION = "Easily create lightweight backups of installed packages, dotfiles, and more."