1717PACKAGE_NAME = "waybacktweets"
1818
1919
20+ class CustomCommand (click .Command ):
21+ """
22+ Custom Click command that overrides the default help message.
23+ """
24+
25+ def format_help (
26+ self , ctx : click .Context , formatter : click .HelpFormatter
27+ ) -> None : # noqa: E501
28+ """
29+ Customize the help message shown when the command is invoked with --help.
30+
31+ Args:
32+ ctx (click.Context): The Click context for the command.
33+ formatter (click.HelpFormatter): The formatter used to generate the help text.
34+ """ # noqa: E501
35+ formatter .write_heading ("Usage" )
36+ formatter .write_text (f" { PACKAGE_NAME } [OPTIONS] USERNAME" )
37+ formatter .write_text (" USERNAME: The Twitter username without @" )
38+
39+ self .format_options (ctx , formatter )
40+
41+ formatter .write_heading ("Examples" )
42+ formatter .write_text (" waybacktweets jack" )
43+ formatter .write_text (
44+ " waybacktweets --from 20200305 --to 20231231 --limit 300 --verbose jack"
45+ )
46+
47+ formatter .write_heading ("Repository" )
48+ formatter .write_text (" https://github.com/claromes/waybacktweets" )
49+
50+ formatter .write_heading ("Documentation" )
51+ formatter .write_text (" https://waybacktweets.claromes.com" )
52+
53+
2054def _parse_date (
2155 ctx : Optional [Any ] = None , param : Optional [Any ] = None , value : Optional [str ] = None
2256) -> Optional [str ]:
@@ -30,7 +64,7 @@ def _parse_date(
3064
3165 Returns:
3266 The input date string formatted in the "YYYYMMDD" format, or None if no date string was provided.
33- """ # noqa: E501
67+ """
3468 try :
3569 if value is None :
3670 return None
@@ -43,15 +77,7 @@ def _parse_date(
4377
4478
4579@click .command (
46- context_settings = {"help_option_names" : ["-h" , "--help" ]},
47- epilog = """
48- Examples:\n
49- Retrieve all tweets: waybacktweets jack\n \n
50- With options and verbose output: waybacktweets --from 20200305 --to 20231231 --limit 300 --verbose jack\n \n
51-
52- Documentation:\n
53- https://waybacktweets.claromes.com/
54- """ , # noqa: E501
80+ cls = CustomCommand , context_settings = {"help_option_names" : ["-h" , "--help" ]}, help = ""
5581)
5682@click .argument ("username" , type = str )
5783@click .option (
@@ -123,8 +149,20 @@ def main(
123149 verbose : Optional [bool ],
124150) -> None :
125151 """
126- USERNAME: The Twitter username without @
127- """
152+ Handles CLI queries for archived tweets with filtering and pagination.
153+
154+ Args:
155+ username (str): Twitter username to search (without the @ symbol).
156+ collapse (Optional[str]): Collapse results based on a specific field or a substring
157+ of a field. Possible values include 'urlkey', 'digest', or 'timestamp:XX', where
158+ XX is the number of digits to match in timestamps (recommended: 4 or more).
159+ timestamp_from (Optional[str]): Start date for filtering results (format: YYYYMMDD).
160+ timestamp_to (Optional[str]): End date for filtering results (format: YYYYMMDD).
161+ limit (Optional[int]): Maximum number of results to return.
162+ resumption_key (Optional[str]): Resume a previous query using this key (for pagination).
163+ matchtype (Optional[str]): Filter by URL match type: 'exact', 'prefix', 'host', or 'domain'.
164+ verbose (Optional[bool]): Print verbose logs during execution.
165+ """ # noqa: E501
128166 try :
129167 config .verbose = verbose
130168
0 commit comments