Skip to content

Commit 9adace5

Browse files
committed
update docs
1 parent 86ff862 commit 9adace5

File tree

5 files changed

+91
-39
lines changed

5 files changed

+91
-39
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ Retrieves archived tweets CDX data from the Wayback Machine, performs necessary
66

77
## Installation
88

9+
Python 3.10+ is required to install `waybacktweets`.
10+
911
```shell
10-
pip install waybacktweets
12+
pipx install waybacktweets
1113
```
1214

15+
[Read more about the installation options](https://waybacktweets.claromes.com/installation).
16+
1317
## CLI
1418

1519
```shell
16-
Usage: waybacktweets [OPTIONS] USERNAME
17-
20+
Usage:
21+
waybacktweets [OPTIONS] USERNAME
1822
USERNAME: The Twitter username without @
1923

2024
Options:
21-
-c, --collapse [urlkey|digest|timestamp:XX]
25+
-c, --collapse [urlkey|digest|timestamp:xx]
2226
Collapse results based on a field, or a
2327
substring of a field. XX in the timestamp
2428
value ranges from 1 to 14, comparing the
@@ -39,16 +43,13 @@ Options:
3943
-v, --verbose Shows the log.
4044
--version Show the version and exit.
4145
-h, --help Show this message and exit.
42-
43-
Examples:
44-
45-
Retrieve all tweets: waybacktweets jack
46-
47-
With options and verbose output: waybacktweets --from 20200305 --to 20231231 --limit 300 --verbose jack
48-
49-
Documentation:
50-
51-
https://waybacktweets.claromes.com/
46+
Examples:
47+
waybacktweets jack
48+
waybacktweets --from 20200305 --to 20231231 --limit 300 --verbose jack
49+
Repository:
50+
https://github.com/claromes/waybacktweets
51+
Documentation:
52+
https://waybacktweets.claromes.com
5253
```
5354

5455
## Module

docs/cli.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ Usage
88
:prog: waybacktweets
99
:nested: full
1010

11+
Examples
12+
---------
13+
14+
``waybacktweets jack``
15+
16+
``waybacktweets --from 20200305 --to 20231231 --limit 300 --verbose jack``
17+
18+
``waybacktweets -f 20200305 -t 20231231 -l 300 -v jack``
19+
1120
Collapsing
1221
------------
1322

docs/installation.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@ Installation
33

44
**It is compatible with Python versions 3.10 and above.**
55

6+
Using pipx
7+
------------
8+
9+
.. code-block:: shell
10+
11+
pipx install waybacktweets
12+
613
Using pip
714
------------
815

916
.. code-block:: shell
1017
11-
pip install waybacktweets
18+
pip3 install waybacktweets
1219
1320
Using Poetry
1421
------------
@@ -38,7 +45,7 @@ From source
3845

3946
.. code-block:: shell
4047
41-
pip install poetry
48+
pip3 install poetry
4249
4350
**Install the dependencies:**
4451

@@ -56,7 +63,7 @@ From source
5663

5764
.. code-block:: shell
5865
59-
poetry run waybacktweets [SUBCOMMANDS]
66+
poetry run waybacktweets [OPTIONS] USERNAME
6067
6168
**Run the Streamlit App:**
6269

@@ -81,5 +88,3 @@ From source
8188
.. code-block:: shell
8289
8390
make clean html
84-
85-
`Read the Poetry CLI documentation <https://python-poetry.org/docs/cli/>`_.

pyproject.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ license = "GPLv3"
77
readme = "README.md"
88
repository = "https://github.com/claromes/waybacktweets"
99
keywords = [
10-
"twitter",
10+
"Twitter",
1111
"X",
1212
"tweet",
13-
"internet-archive",
14-
"wayback-machine",
15-
"osint-tools",
16-
"osint",
17-
"command-line",
13+
"Internet Archive",
14+
"Wayback Machine",
15+
"OSINT",
16+
"SOCMINT",
1817
]
1918
classifiers = [
2019
"Development Status :: 5 - Production/Stable",
@@ -28,7 +27,7 @@ classifiers = [
2827
"Topic :: Software Development",
2928
"Topic :: Utilities",
3029
]
31-
exclude = ["app/**", "assets/**", "docs/**", ".streamlit/**"]
30+
exclude = ["app/**", "legacy_app/**", ".streamlit/**", "assets/**", "docs/**", "build/**", ".github/**", ".git/**", ".gitignore", ".pre-commit-config.yaml", "CITATION.cff"]
3231

3332
[tool.poetry.urls]
3433
"Homepage" = "https://waybacktweets.claromes.com/"
@@ -64,7 +63,7 @@ profile = "black"
6463

6564
[tool.flake8]
6665
max-line-length = 88
67-
extend-ignore = ["E203", "E701"]
66+
extend-ignore = ["E203", "E701", "E501"]
6867

6968
[tool.poetry.scripts]
7069
waybacktweets = 'waybacktweets._cli:main'

waybacktweets/_cli.py

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,40 @@
1717
PACKAGE_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+
2054
def _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

Comments
 (0)