From bcf71df64d0296ee42a236ddcf676cbac8472d9f Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 21 Nov 2023 19:14:31 -0500 Subject: [PATCH] switch from -PROFILE to --PROFILE. improve docs --- README | 2 +- pdt.sh | 46 ++++++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README b/README index de71b2a..1e403d9 100644 --- a/README +++ b/README @@ -27,7 +27,7 @@ account names from a configuration file. Just email me. Main usage: source pdt.sh, run pdt-setup one time, then usually just run pdt to do posts. The documentation for each function is within the -pdt.sh file. +pdt.sh file. After an update via git pull, run pdt-stup again. Patches welcome, email them to iank@fsf.org . If you aren't sure how to send a patch, see https://git-send-email.io/ diff --git a/pdt.sh b/pdt.sh index 01d5998..8c053c0 100644 --- a/pdt.sh +++ b/pdt.sh @@ -26,22 +26,24 @@ _pdtsh_dir="${_pdtsh_file%/*}" _pdtsh_tweet="$_pdtsh_dir/t.py" _pdtsh_blocks=██████████████████████████████████████████████████████████████ -# usage: tweet [-PROFILE_NAME] [POST...] +# usage: tweet [--PROFILE_NAME] [POST...] # Uses variables as input: # $media for image file path. # $alt_text for image alt text. # -# -PROFILE_NAME Either dbd or fsf. Defaults to whatever was used last. +# --PROFILE_NAME Either dbd or fsf. Defaults to whatever profile was used +# last in any pdt command. # # Note retweeting cannot be done with the gratis api level. I suggest # posting a message like: 'Retweet: # https://nitter.net/fsf/status/1726382360826958325' tweet() { - local keys_file + local keys_file profile keys_file=$_pdtsh_dir/twitter_keys.py - if [[ $1 == -* ]]; then + if [[ $1 == --* ]]; then + profile=${1#--} rm -f $keys_file - ln -s $keys_file$1 $keys_file + ln -s $keys_file-$profile $keys_file shift fi @@ -64,9 +66,10 @@ _pdtsh-tweet-option() { option=$1 shift keys_file=$_pdtsh_dir/twitter_keys.py - if [[ $1 == -* ]]; then + if [[ $1 == --* ]]; then + profile=${1#--} rm -f $keys_file - ln -s $keys_file$1 $keys_file + ln -s $keys_file-$profile $keys_file shift fi # shellcheck disable=SC1090 # not relevant to this script @@ -75,59 +78,62 @@ _pdtsh-tweet-option() { deactivate } -# usage: tweetrm [-PROFILE_NAME] POST_ID +# usage: tweetrm [--PROFILE_NAME] POST_ID # # Delete twitter post. Post id is the number at end of a url like: # https://nitter.net/user/status/1725640623149969527 # -# -PROFILE_NAME Either dbd or fsf. Defaults to whatever was used last. +# --PROFILE_NAME see see documentation for tweet() tweetrm() { _pdtsh-tweet-option --delete "$@" } -# usage: pin-tweet [-PROFILE_NAME] POST_ID +# usage: pin-tweet [--PROFILE_NAME] POST_ID # # Pin twitter post. Post id is the number at end of a url like: # https://nitter.net/user/status/1725640623149969527 # -# -PROFILE_NAME Either dbd or fsf. Defaults to whatever was used last. +# --PROFILE_NAME see see documentation for tweet() # pin-tweet() { _pdtsh-tweet-option --pin "$@" } -# usage: unpin-tweet [-PROFILE_NAME] POST_ID +# usage: unpin-tweet [--PROFILE_NAME] POST_ID # # Unpin twitter post. Post id is the number at end of a url like: # https://nitter.net/user/status/1725640623149969527 # -# -PROFILE_NAME Either dbd or fsf. Defaults to whatever was used last. +# --PROFILE_NAME see see documentation for tweet() # unpin-tweet() { _pdtsh-tweet-option --unpin "$@" } -# usage: twitter-banner [-PROFILE_NAME] IMAGE_PATH +# usage: twitter-banner [--PROFILE_NAME] IMAGE_PATH # # IMAGE_PATH Path to jpg or png, 1500 px by 500px. # -# -PROFILE_NAME Either dbd or fsf. Defaults to whatever was used last. +# --PROFILE_NAME see see documentation for tweet() # twitter-banner() { _pdtsh-tweet-option --banner "$@" } -# usage: toot [-PROFILE_NAME] [TOOT_ARGS] +# usage: toot [--PROFILE_NAME] [TOOT_ARGS] +# +# --PROFILE_NAME Either dbd or fsf. Defaults to whatever profile was used +# last in any pdt command. toot() { local mast_profile # shellcheck disable=SC1090 # not relevant to this script source ~/src/toot/venv/bin/activate - if [[ $1 == -* ]]; then - mast_profile=${1#-} + if [[ $1 == --* ]]; then + mast_profile=${1#--} shift command toot activate --quiet $mast_profile || { deactivate; return 1; } fi @@ -143,10 +149,14 @@ toot() { # # -s mastodon|twitter|gnusocial Post to a single social network. # +# --dbd Use dbd account instead of fsf. +# # -m IMAGE_FILE Uploads IMAGE_FILE. if MEDIA_FILE.txt exists, the last # line of that file will be used as ALT_TEXT unless -a # has been used. # +# -a ALT_TEXT Alt-text of IMAGE_FILE. +# # POST can have have some special markup for twitter to deal with the 280 character limit: # # * /tnt/ short for "twitter next tweet". /tnt/ will be removed, and the -- 2.25.1