From 5d54a46aaf3d77c63134a649d4504af9e70945f4 Mon Sep 17 00:00:00 2001 From: Alessio Date: Sat, 14 May 2022 18:18:05 -0700 Subject: [PATCH] Move cmd help message to a plain text file and embed it using go:embed --- cmd/twitter/help_message.txt | 57 +++++++++++++++++++++++++++++++++ cmd/twitter/helpers.go | 61 ++---------------------------------- 2 files changed, 60 insertions(+), 58 deletions(-) create mode 100644 cmd/twitter/help_message.txt diff --git a/cmd/twitter/help_message.txt b/cmd/twitter/help_message.txt new file mode 100644 index 0000000..e03c7d1 --- /dev/null +++ b/cmd/twitter/help_message.txt @@ -0,0 +1,57 @@ +Usage: twitter [--profile ] [] +This application downloads tweets from twitter and saves them in a SQLite database. + +: + Optional. Indicates the path to the directory containing the data directories, database files, and settings files. + By default, will use the current working directory. + Ignored if is "create_profile". + +: + create_profile + is the directory to create. It must not exist already. + will be ignored if provided. + + fetch_user + download_user_content + is the user handle. + "download_user_content" will save a local copy of the user's banner and profile images. + + fetch_tweet + fetch_tweet_only + is either the full URL of the tweet, or its ID. + If using "fetch_tweet_only", then only that specific tweet will be saved. "fetch_tweet" will save the whole + thread including replies. + + download_tweet_content + is either the full URL of the tweet, or its ID. + Downloads videos and images embedded in the tweet. + + get_user_tweets + get_user_tweets_all + is the user handle. + Gets the most recent ~50 tweets. + If "get_user_tweets_all" is used, gets up to ~3200 tweets (API limit). + + follow + unfollow + is the user handle + + list_followed + No is needed; will be ignored if given. + Lists all the users (by their @handle) that are followed. + + search + is the search query. Should be wrapped in quotes if it has spaces. + +: + -h, --help + Print this message, then exit. + + -v, --version + Print the version number and exit. + + -n, --number + Set the number of tweets to fetch, when getting a feed. Default is 50. + Setting this flag means you will get at least that many "tweets plus retweets" from that user (unless of + course they don't have that many). The total amount of tweets returned will be larger, because quoted tweets + won't count toward the limit. diff --git a/cmd/twitter/helpers.go b/cmd/twitter/helpers.go index 4979595..a48d8d3 100644 --- a/cmd/twitter/helpers.go +++ b/cmd/twitter/helpers.go @@ -1,6 +1,7 @@ package main import ( + _ "embed" "fmt" "os" "strconv" @@ -12,64 +13,8 @@ import ( /** * Help message to print if command syntax is incorrect */ -const help_message = `Usage: twitter [--profile ] [] -This application downloads tweets from twitter and saves them in a SQLite database. - -: - Optional. Indicates the path to the directory containing the data directories, database files, and settings files. - By default, will use the current working directory. - Ignored if is "create_profile". - -: - create_profile - is the directory to create. It must not exist already. - will be ignored if provided. - - fetch_user - download_user_content - is the user handle. - "download_user_content" will save a local copy of the user's banner and profile images. - - fetch_tweet - fetch_tweet_only - is either the full URL of the tweet, or its ID. - If using "fetch_tweet_only", then only that specific tweet will be saved. "fetch_tweet" will save the whole - thread including replies. - - download_tweet_content - is either the full URL of the tweet, or its ID. - Downloads videos and images embedded in the tweet. - - get_user_tweets - get_user_tweets_all - is the user handle. - Gets the most recent ~50 tweets. - If "get_user_tweets_all" is used, gets up to ~3200 tweets (API limit). - - follow - unfollow - is the user handle - - list_followed - No is needed; will be ignored if given. - Lists all the users (by their @handle) that are followed. - - search - is the search query. Should be wrapped in quotes if it has spaces. - -: - -h, --help - Print this message, then exit. - - -v, --version - Print the version number and exit. - - -n, --number - Set the number of tweets to fetch, when getting a feed. Default is 50. - Setting this flag means you will get at least that many "tweets plus retweets" from that user (unless of - course they don't have that many). The total amount of tweets returned will be larger, because quoted tweets - won't count toward the limit. -` +//go:embed help_message.txt +var help_message string /** * Helper function