控制台输出格式
是否有任何约定来格式化命令行应用程序的控制台输出以提高可读性和一致性? 例如,您是否缩进子信息,何时打印空行,如果有的话,您应该如何强调重要的陈述。
我发现输出很快就会变得混乱而模糊。 我有兴趣听听其他人在做什么。
更新:实际上,这是针对嵌入式软件的,它可以将调试状态输出到终端,但它非常像控制台应用程序,我认为每个人都会更熟悉这一点。 到目前为止谢谢。
Are there any conventions for formatting console output from a command line app for readability and consistency? For instance, do you indent sub-information, when do you print a blank line, if ever, how should you accent important statements.
I've found output can quickly degenerate into a chaotic blur. I'm interested in hearing about what other people do.
Update: Really this is for embedded software which spits debug status out a terminal, but it's pretty much like a console app, and I figured everyone would be more familiar with that. Thanks so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会区分两种类型的程序:
您是否打印脚本可能使用的信息(即它应该是可解析的)? 然后定义一个相当严格的格式并仅使用该格式(例如固定字段分隔符)。
您是否打印不需要由脚本解析的信息(或者是否已经有替代的脚本可解析格式)? 然后写出自然的内容:
我的建议:
COLUMN
环境变量(以及可能的ROWS
,如果它适用于您的输出)。I'd differentiate two kinds of programs:
Do you print information that might be used by a script (i.e. it should be parseable)? Then define a pretty strict format and use only that (for example fixed field separators).
Do you print information that need not be parsed by a script (or is there an alternative script-parseable format already)? Then write what comes natural:
My suggestions:
COLUMN
environment variable (and possibleROWS
if it applies to your output).如果这是针对 *nix 环境,那么我建议阅读 Unix 哲学基础< /a>. 它并不特定于输出,但对于一般的命令行程序有一些很好的指南。
If this is for a *nix environment, then I'd recommend reading Basics of Unix Philosophy. It's not specific to output but there are some good guidelines for command line programs in general.