Clis should not use dollar signs for argument specification

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the user-input-and-output category.

Last Updated: 2024-11-21

I could not get the reddio library working (FYI: it prints reddit threads to the command line)

You are supposed to be able to pass CLI arguments specifying what reddit fields to display (e.g. the title, url etc.)

I tried as follows:

reddio print -f "$title $url $score" -l 5 r/programming/hot

But nothing printed.

The issue was that the argument had to be in single quotes. In double quotes, my shell was substituting in my local value for $title etc. - which was nil - and effectively send it an empty string.

The solution was to use single quotes:

reddio print -f '$title $url $score' -l 5 r/programming/hot

Were I writing their API, I could use a different symbol than $ to avoid this subtle issue.