Add options for windows and upgrade process
This commit is contained in:
parent
0832e1512a
commit
37852dd06d
3 changed files with 21 additions and 5 deletions
|
@ -11,3 +11,6 @@ def get_io(conf, root):
|
|||
make_abs_path(pathlib.Path(conf.get("in")).expanduser(), root),
|
||||
make_abs_path(pathlib.Path(conf.get("out")).expanduser(), root),
|
||||
)
|
||||
|
||||
def get_yn(args, prompt):
|
||||
return args.default_yes or (not args.default_no and input(prompt).strip().lower() in ["y", ""])
|
||||
|
|
|
@ -7,7 +7,7 @@ import subprocess
|
|||
import sys
|
||||
import tomllib
|
||||
|
||||
from . import get_io
|
||||
from . import get_io, get_yn
|
||||
|
||||
|
||||
logging.config.fileConfig(pathlib.Path(__file__).with_name("log.conf"))
|
||||
|
@ -19,6 +19,8 @@ _argp = argparse.ArgumentParser(
|
|||
)
|
||||
|
||||
_argp.add_argument("-c", "--config", default="config.toml", type=pathlib.Path, help="Configuration file location")
|
||||
_argp.add_argument("-y", "--default-yes", action="store_true", help="Default yes to questions")
|
||||
_argp.add_argument("-n", "--default-no", action="store_true", help="Default no to questions")
|
||||
|
||||
args = _argp.parse_args()
|
||||
|
||||
|
@ -41,12 +43,16 @@ for _name, _conf in config.items():
|
|||
for _package in _conf.get("packages"):
|
||||
_test = subprocess.run(("winget", "list", "--id", _package))
|
||||
if _test.returncode == 0:
|
||||
_yn = input(f"<{_package}> is already installed; reinstall [Yn] ? ").strip().lower()
|
||||
if _yn != "y" and _yn != "":
|
||||
if not get_yn(args, f"<{_package}> is already installed; reinstall [Yn] ? "):
|
||||
log.info(f"> Skipping <{_package}> install.")
|
||||
continue
|
||||
log.info(f"> Installing {_package} using winget.")
|
||||
subprocess.run(("winget", "install", _package))
|
||||
case "windowsoptionalfeatures":
|
||||
log.info("Enabling Windows Optional Features.")
|
||||
for _feature in _conf.get("features"):
|
||||
log.info(f"> Enabling {_feature}.")
|
||||
subprocess.run(("dism", "-Online", "-Add-Capability", f"-CapabilityName:{_feature}"))
|
||||
case _:
|
||||
_in, _out = get_io(_conf, _root)
|
||||
log.info(f"Installing {_name} configuration from <{_in}> to <{_out}>.")
|
||||
|
@ -56,8 +62,7 @@ for _name, _conf in config.items():
|
|||
|
||||
if _out.exists():
|
||||
if _out.is_file():
|
||||
_yn = input(f"<{_out}> already exists; replace [Yn] ? ").strip().lower()
|
||||
if _yn != "y" and _yn != "":
|
||||
if not get_yn(args, f"<{_out}> already exists; replace [Yn] ? "):
|
||||
log.info(f"> Skipping {_name} configuration.")
|
||||
continue
|
||||
else:
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
packages = [
|
||||
"Git.Git",
|
||||
"Neovim.Neovim",
|
||||
"GnuPG.GnuPG",
|
||||
"Discord.Discord",
|
||||
"Microsoft.PowerToys",
|
||||
]
|
||||
|
||||
[WindowsOptionalFeatures]
|
||||
features = [
|
||||
"Media.MediaFeaturePack"
|
||||
]
|
||||
|
||||
[PowerShell]
|
||||
|
|
Loading…
Reference in a new issue