Add update option
This commit is contained in:
parent
ecf6b25b5f
commit
dd1222e369
2 changed files with 15 additions and 4 deletions
17
install.py
17
install.py
|
@ -18,13 +18,14 @@ import ruamel.yaml
|
||||||
class Installer:
|
class Installer:
|
||||||
"""Regroups all the installation methods listed in the yaml conf file."""
|
"""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
|
self.conf = ruamel.yaml.safe_load( # type: ignore
|
||||||
Path("configs.yml").text()
|
Path("configs.yml").text()
|
||||||
)
|
)
|
||||||
self.base_dir = Path.getcwd()
|
self.base_dir = Path.getcwd()
|
||||||
self.home = Path("~").expanduser()
|
self.home = Path("~").expanduser()
|
||||||
self.force = force
|
self.force = force
|
||||||
|
self.update = update
|
||||||
|
|
||||||
def pretty_path(self, path: Path) -> str:
|
def pretty_path(self, path: Path) -> str:
|
||||||
"""Put the ~/ back in the path."""
|
"""Put the ~/ back in the path."""
|
||||||
|
@ -43,6 +44,10 @@ class Installer:
|
||||||
if self.force:
|
if self.force:
|
||||||
ui.info_2("Removing", pretty_dest)
|
ui.info_2("Removing", pretty_dest)
|
||||||
p_dest.rmtree()
|
p_dest.rmtree()
|
||||||
|
elif self.update:
|
||||||
|
ui.info_2("Updating", pretty_dest)
|
||||||
|
self.do_run("cd {} && git pull".format(p_dest))
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
ui.info_2("Skipping", pretty_dest)
|
ui.info_2("Skipping", pretty_dest)
|
||||||
return
|
return
|
||||||
|
@ -191,13 +196,19 @@ def main() -> None:
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Overwrite existing files",
|
help="Overwrite existing files",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--update",
|
||||||
|
action="store_true",
|
||||||
|
help="Update git repos",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
force = args.force
|
|
||||||
programs = args.programs
|
programs = args.programs
|
||||||
|
force = args.force
|
||||||
|
update = args.update
|
||||||
|
|
||||||
installer = Installer(force=force)
|
installer = Installer(force=force, update=update)
|
||||||
installer.install(programs=programs)
|
installer.install(programs=programs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,6 @@ setup_vim() { # {{{
|
||||||
# install_rust
|
# install_rust
|
||||||
# setup_vim
|
# setup_vim
|
||||||
# setup_sddm
|
# setup_sddm
|
||||||
setup_i3
|
# setup_i3
|
||||||
# markdown_mimetype
|
# markdown_mimetype
|
||||||
# clone_projects
|
# clone_projects
|
||||||
|
|
Loading…
Add table
Reference in a new issue