将数据管道输出到字符串或文件(.piped)

bin_directory/command1

#!/bin/bash
echo hello $1
bin_directory/command2
#!/bin/bash
echo hello $1 1>&2

from commandlib import CommandPath
command_path = CommandPath("./bin_directory")

标准输出到文件句柄

with open("regular", "w") as handle:
    command_path.command1("harry").piped.stdout_to_handle(handle).run()

文件“regular”将包含

hello harry

标准输出到文件名

command_path.command1("harry").piped.stdout_to_filename("regular").run()

文件“regular”将包含

hello harry

标准错误到文件句柄

with open("error", "w") as handle:
    command_path.command2("tom").piped.stderr_to_handle(handle).run()

文件“error”将包含

hello tom

可执行规范

文档从 pipe.story storytests. 自动生成。