kalekundert / stepwise

Modular, command-line scientific protocols
GNU General Public License v3.0
3 stars 0 forks source link

Add `note` command to add footnotes via CLI #27

Closed kalekundert closed 4 years ago

kalekundert commented 4 years ago

This command would basically have two arguments: a pattern and a message. It would read a protocol from stdin, insert a footnote reference before/after the given pattern, add the footnote to the protocol, and print the protocol to stdout. The pattern would be optional; the default would be to put the footnote at the end of the previous step.

Here is the usage I'm imagining:

Insert a footnote into a protocol.

This command can be used to elaborate on a previous step in a protocol.  The 
footnote will be numbered automatically, and will be correct even if the footnote 
is inserted before other footnotes.

Usage:
    note <message> 

Arguments:
    <message>
         The text of the footnote to add.

Options:
    -w --where PATTERN
        Indicate where the footnote reference should be placed.  The reference 
        will be inserted directly after the first substring that matched the pattern, 
        starting at the end of the protocol and moving towards the front.  You can 
        use a lookahead assertion to match text that will appear after the reference, 
        e.g. '(?=:)' will place a reference before the first colon that is found.  By 
        default the footnote will be placed at the end of the last step in the protocol.

    -r --raw
        Do not automatically line-wrap the given message.  The default is to wrap 
        the message to a maximum width of 49 characters.

It's tempting to let zsh users provide the footnote via a heredoc, but that would require really reaching into the guts of ProtocolIO, and would break the rule that stdin parsing works the same for all stepwise commands.

kalekundert commented 4 years ago

Fixed by 904fdf6