Add update option

This commit is contained in:
flyingscorpio@pinebook-pro 2020-04-19 11:13:09 +02:00
parent ecf6b25b5f
commit dd1222e369
2 changed files with 15 additions and 4 deletions

View file

@ -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)

View file

@ -330,6 +330,6 @@ setup_vim() { # {{{
# install_rust
# setup_vim
# setup_sddm
setup_i3
# setup_i3
# markdown_mimetype
# clone_projects