Add hide command option
This commit is contained in:
parent
2d43389f9f
commit
201b9944a2
1 changed files with 24 additions and 4 deletions
28
install.py
28
install.py
|
@ -19,7 +19,11 @@ 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__(
|
def __init__(
|
||||||
self, force: bool = False, first_install: bool = False, update: bool = False
|
self,
|
||||||
|
force: bool = False,
|
||||||
|
first_install: bool = False,
|
||||||
|
update: bool = False,
|
||||||
|
hide_commands: bool = False,
|
||||||
):
|
):
|
||||||
yaml = YAML(typ="safe")
|
yaml = YAML(typ="safe")
|
||||||
self.conf = yaml.load(Path("configs.yml").text())
|
self.conf = yaml.load(Path("configs.yml").text())
|
||||||
|
@ -29,6 +33,7 @@ class Installer:
|
||||||
self.force = force
|
self.force = force
|
||||||
self.first_install = first_install
|
self.first_install = first_install
|
||||||
self.update = update
|
self.update = update
|
||||||
|
self.hide_commands = hide_commands
|
||||||
|
|
||||||
def evaluate_condition(self, condition: str) -> bool:
|
def evaluate_condition(self, condition: str) -> bool:
|
||||||
"""Run a bash command. On success return True, else return False."""
|
"""Run a bash command. On success return True, else return False."""
|
||||||
|
@ -146,6 +151,12 @@ class Installer:
|
||||||
|
|
||||||
failed_installs = []
|
failed_installs = []
|
||||||
|
|
||||||
|
this_stdout: Optional[int] = None
|
||||||
|
this_stderr: Optional[int] = None
|
||||||
|
if self.hide_commands:
|
||||||
|
this_stdout = subprocess.DEVNULL
|
||||||
|
this_stderr = subprocess.DEVNULL
|
||||||
|
|
||||||
ui.info_2("Installing packages...")
|
ui.info_2("Installing packages...")
|
||||||
for i, package in enumerate(packages):
|
for i, package in enumerate(packages):
|
||||||
if self.operating_system == "arch based":
|
if self.operating_system == "arch based":
|
||||||
|
@ -158,8 +169,8 @@ class Installer:
|
||||||
command,
|
command,
|
||||||
check=False,
|
check=False,
|
||||||
shell=True,
|
shell=True,
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=this_stdout,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=this_stderr,
|
||||||
)
|
)
|
||||||
|
|
||||||
if install.returncode != 0:
|
if install.returncode != 0:
|
||||||
|
@ -397,6 +408,9 @@ def main() -> None:
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-u", "--update", action="store_true", help="Update git repos",
|
"-u", "--update", action="store_true", help="Update git repos",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-H", "--hide_commands", action="store_true", help="Hide command outputs",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -407,8 +421,14 @@ def main() -> None:
|
||||||
generate = args.generate
|
generate = args.generate
|
||||||
list_programs = args.list_programs
|
list_programs = args.list_programs
|
||||||
update = args.update
|
update = args.update
|
||||||
|
hide_commands = args.hide_commands
|
||||||
|
|
||||||
installer = Installer(force=force, first_install=first_install, update=update)
|
installer = Installer(
|
||||||
|
force=force,
|
||||||
|
first_install=first_install,
|
||||||
|
update=update,
|
||||||
|
hide_commands=hide_commands,
|
||||||
|
)
|
||||||
|
|
||||||
if generate:
|
if generate:
|
||||||
installer.generate_process_list()
|
installer.generate_process_list()
|
||||||
|
|
Loading…
Add table
Reference in a new issue