Open kalekundert opened 3 years ago
This would also be helpful for outputting command line usage text. Right now I output this text to stderr to kinda circumvent the whole problem. But it might be better to just use stdout in "not protocol output" mode.
Currently, anything a protocol script writes to stdout is interpreted as a protocol, and errors are generated if it cannot be parsed as such. However, I'd like to be able to do things like:
In other words, the
sw cond
command has access to information (the number of conditions to test) that could be useful in the rest of the script. This would help prevent bugs where I forget to update these kinds of numbers.My initial thought for how to do this is to add a
enable_direct_output()
function to stepwise that toggles a global variable controlling whether the main function will attempt to parse protocol output as a protocol. I have to think more about how such a variable might propogate to subprocesses, though.It's worth mentioning that the ability to output directly to stdout is one of the main distinctions between "protocols" (e.g.
cond
,step
,reaction
) and "subcommands" (e.g.ls
,stash
,go
). This feature weakens that distinction, and suggests that maybe the distinction should be removed altogether. However, I don't think it should be. Another difference is that subcommands can't be shadowed by protocols, and I think that's also important.