From dd1222e36936ccf168158137aa9bccc2823a9a9a Mon Sep 17 00:00:00 2001 From: "flyingscorpio@pinebook-pro" Date: Sun, 19 Apr 2020 11:13:09 +0200 Subject: [PATCH] Add update option --- install.py | 17 ++++++++++++++--- main_install.sh | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/install.py b/install.py index 8fe3787..e6881d9 100755 --- a/install.py +++ b/install.py @@ -18,13 +18,14 @@ import ruamel.yaml class Installer: """Regroups all the installation methods listed in the yaml conf file.""" - def __init__(self, force: bool = False): + def __init__(self, force: bool = False, update: bool = False): self.conf = ruamel.yaml.safe_load( # type: ignore Path("configs.yml").text() ) self.base_dir = Path.getcwd() self.home = Path("~").expanduser() self.force = force + self.update = update def pretty_path(self, path: Path) -> str: """Put the ~/ back in the path.""" @@ -43,6 +44,10 @@ class Installer: if self.force: ui.info_2("Removing", pretty_dest) p_dest.rmtree() + elif self.update: + ui.info_2("Updating", pretty_dest) + self.do_run("cd {} && git pull".format(p_dest)) + return else: ui.info_2("Skipping", pretty_dest) return @@ -191,13 +196,19 @@ def main() -> None: action="store_true", help="Overwrite existing files", ) + parser.add_argument( + "--update", + action="store_true", + help="Update git repos", + ) args = parser.parse_args() - force = args.force programs = args.programs + force = args.force + update = args.update - installer = Installer(force=force) + installer = Installer(force=force, update=update) installer.install(programs=programs) diff --git a/main_install.sh b/main_install.sh index 63556e6..36f8f2c 100755 --- a/main_install.sh +++ b/main_install.sh @@ -330,6 +330,6 @@ setup_vim() { # {{{ # install_rust # setup_vim # setup_sddm -setup_i3 +# setup_i3 # markdown_mimetype # clone_projects