Skip to content

Commit

Permalink
refactor: Remove deprecated purge CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Dec 14, 2019
1 parent 6baf63c commit 8668c8d
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions src/aria2p/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ def main(args=None):
"rm": subcommand_remove, # alias for remove
"del": subcommand_remove, # alias for remove
"delete": subcommand_remove, # alias for remove
"purge": subcommand_purge,
"clear": subcommand_purge, # alias for purge
"autopurge": subcommand_autopurge,
"autoclear": subcommand_autopurge, # alias for autopurge
"listen": subcommand_listen,
Expand Down Expand Up @@ -178,7 +176,6 @@ def subparser(command, text, **kwargs):
subparser("autopurge", "Automatically purge completed/removed/failed downloads.", aliases=["autoclear"])
call_parser = subparser("call", "Call a remote method through the JSON-RPC client.")
pause_parser = subparser("pause", "Pause downloads.", aliases=["stop"])
purge_parser = subparser("purge", "Purge downloads.", aliases=["clear"])
remove_parser = subparser("remove", "Remove downloads.", aliases=["rm", "del", "delete"])
resume_parser = subparser("resume", "Resume downloads.", aliases=["start"])
subparser("show", "Show the download progression.")
Expand Down Expand Up @@ -239,10 +236,6 @@ def subparser(command, text, **kwargs):
"-f", "--force", dest="force", action="store_true", help="Remove without contacting servers first."
)

# ========= PURGE PARSER ========= #
purge_parser.add_argument("gids", nargs="*", help="The GIDs of the downloads to purge.")
purge_parser.add_argument("-a", "--all", action="store_true", dest="do_all", help="Purge all the downloads.")

# ========= LISTEN PARSER ========= #
listen_parser.add_argument(
"-c",
Expand Down Expand Up @@ -602,38 +595,6 @@ def subcommand_remove(api: API, gids=None, do_all=False, force=False):
return 1


def subcommand_purge(api: API, gids=None, do_all=False):
"""
Purge subcommand.
Args:
api (API): the API instance to use.
gids (list of str): the GIDs of the downloads to purge.
do_all (bool): pause all downloads if True.
Returns:
int: 0 if all success, 1 if one failure.
"""
print(
"Deprecation warning: command 'purge' is deprecated in favor of command 'remove', "
"and will be removed in version 0.7.0.",
file=sys.stderr,
)
if do_all:
if api.purge_all():
return 0
return 1

downloads = [Download(api, {"gid": gid}) for gid in gids]
result = api.purge(downloads)
if all(result):
return 0
for item in result:
if isinstance(item, ClientException):
print(item, file=sys.stderr)
return 1


def subcommand_autopurge(api: API):
"""
Autopurge subcommand.
Expand Down

0 comments on commit 8668c8d

Please sign in to comment.