Skip to content

Commit

Permalink
feat: Combine -all commands to normal ones, with -a, --all option
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Mar 2, 2019
1 parent 73333d9 commit e5d287c
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 139 deletions.
59 changes: 8 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,8 @@ Commands:
call Call a remote method through the JSON-RPC client.
pause Pause downloads.
purge (clear) Purge downloads.
pause-all Pause all downloads.
remove (rm) Remove downloads.
remove-all Remove all downloads.
resume Resume downloads.
resume-all Resume all downloads.
show Show the download progression.
```
Expand Down Expand Up @@ -162,11 +159,8 @@ Commands:
- [`call`](#call)
- [`pause`](#pause)
- [`purge`](#purge)
- [`pause-all`](#pause-all)
- [`remove`](#remove)
- [`remove-all`](#remove-all)
- [`resume`](#resume)
- [`resume-all`](#resume-all)
- [`show`](#show)


Expand Down Expand Up @@ -344,7 +338,7 @@ $ aria2p call purge_download_result

### `pause`
```
usage: aria2p pause [-h] [-f] gids [gids ...]
usage: aria2p pause [-h] [-a] [-f] [gids [gids ...]]
Pause downloads.
Expand All @@ -353,6 +347,7 @@ positional arguments:
optional arguments:
-h, --help Show this help message and exit.
-a, --all Pause all the downloads.
-f, --force Pause without contacting servers first.
```
Expand All @@ -361,7 +356,7 @@ optional arguments:

### `purge`
```
usage: aria2p purge [-h] [gids [gids ...]]
usage: aria2p purge [-h] [-a] [gids [gids ...]]
Purge downloads.
Expand All @@ -370,28 +365,15 @@ positional arguments:
optional arguments:
-h, --help Show this help message and exit.
```



### `pause-all`
```
usage: aria2p pause-all [-h] [-f]
Pause all downloads.
optional arguments:
-h, --help Show this help message and exit.
-f, --force Pause without contacting servers first.
-a, --all Purge all the downloads.
```



### `remove`
```
usage: aria2p remove [-h] [-f] gids [gids ...]
usage: aria2p remove [-h] [-a] [-f] [gids [gids ...]]
Remove downloads.
Expand All @@ -400,20 +382,7 @@ positional arguments:
optional arguments:
-h, --help Show this help message and exit.
-f, --force Remove without contacting servers first.
```



### `remove-all`
```
usage: aria2p remove-all [-h] [-f]
Remove all downloads.
optional arguments:
-h, --help Show this help message and exit.
-a, --all Remove all the downloads.
-f, --force Remove without contacting servers first.
```
Expand All @@ -422,7 +391,7 @@ optional arguments:

### `resume`
```
usage: aria2p resume [-h] gids [gids ...]
usage: aria2p resume [-h] [-a] [gids [gids ...]]
Resume downloads.
Expand All @@ -431,19 +400,7 @@ positional arguments:
optional arguments:
-h, --help Show this help message and exit.
```



### `resume-all`
```
usage: aria2p resume-all [-h]
Resume all downloads.
optional arguments:
-h, --help Show this help message and exit.
-a, --all Resume all the downloads.
```

Expand Down
9 changes: 9 additions & 0 deletions src/aria2p/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@

# TODO: use proper logging messages (esp. in except: pass)
# TODO: maybe add type annotations

# Roadmap:
# - feature: Ability to hide metadata downloads (magnet URIs)
# - feature: Ability to move files to another directory
# - feature: Ability to tag downloads with markers (like categories)
# - feature: Ability to execute instructions on events (download completed, etc.)
# - feature: Improved queue
# - feature: Interactive display (htop-style) with sorting, filtering and actions
# - feature: Ability to search current downloads with patterns and filters on fields
10 changes: 10 additions & 0 deletions src/aria2p/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def purge(self, downloads):
Returns:
list of bool: Success or failure of the operation for each download.
"""
# TODO: batch/multicall candidate
result = []

for download in downloads:
Expand All @@ -464,6 +465,15 @@ def purge(self, downloads):

return result

def purge_all(self):
"""
Purge all downloads from the list.
Returns:
bool: Success or failure of the operation to purge all downloads.
"""
return all(self.purge(self.get_downloads()))

def get_options(self, downloads):
"""
Get options for each of the given downloads.
Expand Down
Loading

0 comments on commit e5d287c

Please sign in to comment.