Improve ergonomics updating positional arguments #2

Open
opened 2025-10-22 02:41:00 +08:00 by panda · 5 comments
Owner

Idea: Make litblock take file or - for stdin as first positional argument, or make it take --file flag, and make pattern default.

Perhaps: Default actions be to show help, list listblocks if file in position 1, then pattern

Idea: Make litblock take file or - for stdin as first positional argument, or make it take --file flag, and make pattern default. Perhaps: Default actions be to show help, list listblocks if file in position 1, then pattern
Author
Owner

existing

#!/usr/bin/env sh
echo "An issue was added to litblock to change the positional argument ordering in the future"
CURRENT_FILE="$HOME/notes/2025-10-22.md"
litblock "work breakdown" "$CURRENT_FILE"
litblock "ensure analysis document" "$CURRENT_FILE" | sh -
existing ```sh «run litblock file» #!/usr/bin/env sh echo "An issue was added to litblock to change the positional argument ordering in the future" CURRENT_FILE="$HOME/notes/2025-10-22.md" litblock "work breakdown" "$CURRENT_FILE" litblock "ensure analysis document" "$CURRENT_FILE" | sh - ```
Author
Owner

this was meant to work, possibly break into separate issue, but its annoying to have to look up the man page, it is expected that would work when using '<,'>w !cat | sh - in vim, which brings up some design considerations.

#!/usr/bin/env -S sh
echo "An issue was added to litblock to change the positional argument ordering in the future"
export LITBLOCK_SRC="$HOME/notes/2025-10-22.md"
litblock "work breakdown" 
litblock "ensure analysis document"  | sh -
this was meant to work, possibly break into separate issue, but its annoying to have to look up the man page, it is expected that would work when using `'<,'>w !cat | sh -` in vim, which brings up some design considerations. ```sh #!/usr/bin/env -S sh echo "An issue was added to litblock to change the positional argument ordering in the future" export LITBLOCK_SRC="$HOME/notes/2025-10-22.md" litblock "work breakdown" litblock "ensure analysis document" | sh - ```
Author
Owner

Need to consider 'fd . -t f | xargs -0 -d\n litblock "$pattern"' and the stdin :w !cat | sh - in vim use cases. And using like litblock "$FILE" i guess we use xargs to pipe filenames, and stdin...

Note: Need to figure out how to clearly state what I mean above, in a future edit.

Need to consider 'fd . -t f | xargs -0 -d\n litblock "$pattern"' and the stdin `:w !cat | sh -` in vim use cases. And using like `litblock "$FILE"` i guess we use xargs to pipe filenames, and stdin... Note: Need to figure out how to clearly state what I mean above, in a future edit.
Author
Owner

the goal should be to make it so the variable length argument is at the end, so I can use visual block selection to use cw to edit multiple lines easily in documents.

So using - for stdin might be best so I can use

#!/usr/bin/env sh
echo "An issue was added to litblock to change the positional argument ordering in the future"
CURRENT_FILE="$HOME/notes/2025-10-22.md"
litblock "$CURRENT_FILE" "work breakdown" 
litblock "$CURRENT_FILE"  "ensure analysis document"  | sh -

but this will require considering the environment variable process. So lets see how I go, if i can make it use both, maybe --file=... might be needed if I get the env var method to work better

the goal should be to make it so the variable length argument is at the end, so I can use visual block selection to use `cw` to edit multiple lines easily in documents. So using `-` for stdin might be best so I can use ``` #!/usr/bin/env sh echo "An issue was added to litblock to change the positional argument ordering in the future" CURRENT_FILE="$HOME/notes/2025-10-22.md" litblock "$CURRENT_FILE" "work breakdown" litblock "$CURRENT_FILE" "ensure analysis document" | sh - ``` but this will require considering the environment variable process. So lets see how I go, if i can make it use both, maybe --file=... might be needed if I get the env var method to work better
Author
Owner

Heres the literate markdown section for context (indented to make literate block readable)

        Usage: litblock <pattern> [file]

    
    ```sh «run litblock file»
    #!/usr/bin/env sh
    echo "An issue was added to litblock to change the positional argument ordering in the future"
    CURRENT_FILE="$HOME/notes/2025-10-22.md"
    litblock "work breakdown" "$CURRENT_FILE"
    litblock "ensure analysis document" "$CURRENT_FILE" | sh -
    ```
    
    ```sh «ensure analysis document»
    BASE_PATH="$HOME/notes/wiki/infra"
    ensure_file(){
        local dest_path="$1"
        local directory="$(printf "%s\n" "$(dirname "$dest_path")")"
        printf 'mkdir -p "%s"\n' "$directory"
        mkdir -p "$directory"
        printf 'touch "%s"\n' "$dest_path"
        touch "$dest_path"
    }
    
    ensure_file "$BASE_PATH/pandas-thinkpad.md"
    ```
Heres the literate markdown section for context (indented to make literate block readable) Usage: litblock <pattern> [file] ```sh «run litblock file» #!/usr/bin/env sh echo "An issue was added to litblock to change the positional argument ordering in the future" CURRENT_FILE="$HOME/notes/2025-10-22.md" litblock "work breakdown" "$CURRENT_FILE" litblock "ensure analysis document" "$CURRENT_FILE" | sh - ``` ```sh «ensure analysis document» BASE_PATH="$HOME/notes/wiki/infra" ensure_file(){ local dest_path="$1" local directory="$(printf "%s\n" "$(dirname "$dest_path")")" printf 'mkdir -p "%s"\n' "$directory" mkdir -p "$directory" printf 'touch "%s"\n' "$dest_path" touch "$dest_path" } ensure_file "$BASE_PATH/pandas-thinkpad.md" ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
panda/litblock#2
No description provided.