def printCommand(arg1: "typing.Union[str, typing.Sequence[typing.Any]]", *remainingArgs, outputFile=None,
colour=AnsiColour.yellow, cwd=None, env=None, sep=" ", printVerboseOnly=False, **kwargs):
if not _cheriConfig or (_cheriConfig.quiet or (printVerboseOnly and not _cheriConfig.verbose)):
return
# also allow passing a single string
if not type(arg1) is str:
allArgs = arg1
arg1 = allArgs[0]
remainingArgs = allArgs[1:]
newArgs = ("cd", shlex.quote(str(cwd)), "&&") if cwd else tuple()
if env:
# only print the changed environment entries
filteredEnv = __filterEnv(env)
if filteredEnv:
newArgs += ("env",) + tuple(map(shlex.quote, (k + "=" + str(v) for k, v in filteredEnv.items())))
# comma in tuple is required otherwise it creates a tuple of string chars
newArgs += (shlex.quote(str(arg1)),) + tuple(map(shlex.quote, map(str, remainingArgs)))
if outputFile:
newArgs += (">", str(outputFile))
print(coloured(colour, newArgs, sep=sep), flush=True, **kwargs)
评论列表
文章目录