Update config file location

This commit is contained in:
Edgar P. Burkhart 2022-11-01 08:11:32 +01:00
parent 1f862145ea
commit 0832e1512a
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 16 additions and 9 deletions

View file

@ -1,3 +0,0 @@
[PowerShell]
in="src/PowerShell/profile.ps1"
out="~/Documents/WindowsPowerShell"

View file

@ -1,5 +1,13 @@
import pathlib
def get_io(conf):
return pathlib.Path(conf.get("in")).expanduser(), pathlib.Path(conf.get("out")).expanduser()
def make_abs_path(path, root):
if not path.is_absolute():
return root.joinpath(path)
return path
def get_io(conf, root):
return (
make_abs_path(pathlib.Path(conf.get("in")).expanduser(), root),
make_abs_path(pathlib.Path(conf.get("out")).expanduser(), root),
)

View file

@ -32,6 +32,8 @@ except FileNotFoundError:
log.error(f"Configuration file <{args.config}> does not exist.")
sys.exit(1)
_root = args.config.parent
for _name, _conf in config.items():
match _name.lower():
case "winget":
@ -46,7 +48,7 @@ for _name, _conf in config.items():
log.info(f"> Installing {_package} using winget.")
subprocess.run(("winget", "install", _package))
case _:
_in, _out = get_io(_conf)
_in, _out = get_io(_conf, _root)
log.info(f"Installing {_name} configuration from <{_in}> to <{_out}>.")
if not _in.is_file():
log.error(f"> {_name} configuration <{_in}> could not be found.")

View file

@ -5,13 +5,13 @@ packages = [
]
[PowerShell]
in="src/PowerShell/profile.ps1"
in="PowerShell/profile.ps1"
out="~/Documents/WindowsPowerShell/profile.ps1"
[Git]
in="src/Git/gitconfig-win"
in="Git/gitconfig-win"
out="~/.gitconfig"
[Neovim]
in="src/Neovim/init.vim"
in="Neovim/init.vim"
out="~/AppData/Local/nvim/init.vim"