Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add all keyword to group run #52

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,16 @@ tegracli-project/
|- 10000001.jsonl
|- 10000002.jsonl
```
To run the project command your terminal to `tegracli group run my_group` to collect the latest post of the accounts you want to track.

To run the project command your terminal to `tegracli group run my_group` to collect the latest post of the accounts you want to track. If you have multiple groups configured you can run all by running `tegracli group run all`. This interprets all subdirectories as valid groups. However, `tegracli` will fail if a subdirectory is not a valid group.

```text
Usage: tegracli group run [OPTIONS] [GROUPS]...

load a group configuration and run the groups operations
Load a group configuration and run the groups operations.

GROUPS are subdirectories with a valid group configuration.
If the special keyword all is given, all subdirectories are considered.
```

## Result File Format
Expand Down
15 changes: 14 additions & 1 deletion tegracli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ def reset(groups: Tuple[str]):
@click.argument("groups", nargs=-1)
@click.pass_context
def run(ctx: click.Context, groups: Tuple[str]):
"""Load a group configuration and run the groups operations."""
"""Load a group configuration and run the groups operations.

GROUPS are subdirectories with a valid group configuration.
If the special keyword all is given, all subdirectories are considered.
"""
client = ctx.obj["client"]
with client:
run_group(client, groups)
Expand Down Expand Up @@ -352,6 +356,15 @@ def run_group(client: TelegramClient, groups: Tuple[str]):
"""Runs the required operations for the specified groups."""
cwd = Path()

if groups == ("all", ):
groups = [
path
for path
in Path().iterdir()
if path.is_dir()
and not path.name.startswith(".")
]

# iterate groups
for group_name in groups:
# load group configuration
Expand Down