clan-cli: Add -L option to nixos-rebuild switch to still have build output, simplify logging code
This commit is contained in:
@@ -12,6 +12,7 @@ from typing import IO, Any
|
||||
|
||||
from clan_cli.cmd import Log, MsgColor
|
||||
from clan_cli.cmd import run as local_run
|
||||
from clan_cli.colors import AnsiColor
|
||||
from clan_cli.ssh.host_key import HostKeyCheck
|
||||
|
||||
cmdlog = logging.getLogger(__name__)
|
||||
@@ -38,12 +39,6 @@ class Host:
|
||||
if not self.command_prefix:
|
||||
self.command_prefix = self.host
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return str(self)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.user}@{self.host}" + str(self.port if self.port else "")
|
||||
|
||||
@property
|
||||
def target(self) -> str:
|
||||
return f"{self.user or 'root'}@{self.host}"
|
||||
@@ -83,7 +78,6 @@ class Host:
|
||||
env=env,
|
||||
cwd=cwd,
|
||||
log=log,
|
||||
logger=cmdlog,
|
||||
check=check,
|
||||
error_msg=error_msg,
|
||||
msg_color=msg_color,
|
||||
@@ -117,7 +111,13 @@ class Host:
|
||||
env.update(extra_env)
|
||||
|
||||
displayed_cmd = " ".join(cmd)
|
||||
cmdlog.info(f"$ {displayed_cmd}", extra={"command_prefix": self.command_prefix})
|
||||
cmdlog.info(
|
||||
f"$ {displayed_cmd}",
|
||||
extra={
|
||||
"command_prefix": self.command_prefix,
|
||||
"color": AnsiColor.GREEN.value,
|
||||
},
|
||||
)
|
||||
return self._run(
|
||||
cmd,
|
||||
shell=shell,
|
||||
@@ -170,7 +170,13 @@ class Host:
|
||||
export_cmd = f"export {' '.join(env_vars)}; "
|
||||
displayed_cmd += export_cmd
|
||||
displayed_cmd += " ".join(cmd)
|
||||
cmdlog.info(f"$ {displayed_cmd}", extra={"command_prefix": self.command_prefix})
|
||||
cmdlog.info(
|
||||
f"$ {displayed_cmd}",
|
||||
extra={
|
||||
"command_prefix": self.command_prefix,
|
||||
"color": AnsiColor.GREEN.value,
|
||||
},
|
||||
)
|
||||
|
||||
# Build the ssh command
|
||||
bash_cmd = export_cmd
|
||||
|
||||
Reference in New Issue
Block a user