diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a347786..2c4288b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format mostly follows [Keep a Changelog](http://keepachangelog.com/en/1.0.0/ ### Added - New `enabled` option for all jobs. Set to false to disable a job without needing to remove it or comment it out (Requested in #625 by snowman, contributed in #785 by jamstah) +- Command line options to enable and disbale jobs (Requested in #813 by gapato, contributed in #820 by jamstah) - New option `ignore_incomplete_reads` (Requested in #725 by wschoot, contributed in #787 by wfrisch) - New option `wait_for` in browser jobs (Requested in #763 by yuis-ice, contributed in #810 by jamstah) - Added tags to jobs and the ability to select them at the command line (#789, #824 by jamstah) diff --git a/docs/source/manpage.rst b/docs/source/manpage.rst index fa3b41b1..199fd2af 100644 --- a/docs/source/manpage.rst +++ b/docs/source/manpage.rst @@ -76,6 +76,12 @@ job list management: --delete JOB delete job by location or index + --enable JOB + enable job by location or index + + --disable JOB + delete job by location or index + --change_location JOB NEW_LOCATION change the location of an existing job by location or index diff --git a/lib/urlwatch/command.py b/lib/urlwatch/command.py index 01f09a97..9ba175c0 100644 --- a/lib/urlwatch/command.py +++ b/lib/urlwatch/command.py @@ -199,6 +199,24 @@ def modify_urls(self): print('Not found: %r' % (self.urlwatch_config.delete,)) save = False + if self.urlwatch_config.enable is not None: + job = self._find_job(self.urlwatch_config.enable) + if job is not None: + job.enabled = True + print(f'Enabled {job!r}') + else: + print(f'Not found: {self.urlwatch_config.enable!r}') + save = False + + if self.urlwatch_config.disable is not None: + job = self._find_job(self.urlwatch_config.disable) + if job is not None: + job.enabled = False + print(f'Disabled {job!r}') + else: + print(f'Not found: {self.urlwatch_config.disable!r}') + save = False + if self.urlwatch_config.add is not None: # Allow multiple specifications of filter=, so that multiple filters can be specified on the CLI items = [item.split('=', 1) for item in self.urlwatch_config.add.split(',')] @@ -262,6 +280,8 @@ def handle_actions(self): sys.exit(self.list_urls()) if (self.urlwatch_config.add is not None or self.urlwatch_config.delete is not None + or self.urlwatch_config.enable is not None + or self.urlwatch_config.disable is not None or self.urlwatch_config.change_location is not None): sys.exit(self.modify_urls()) diff --git a/lib/urlwatch/config.py b/lib/urlwatch/config.py index f5d1ec5c..d5151c3b 100644 --- a/lib/urlwatch/config.py +++ b/lib/urlwatch/config.py @@ -91,6 +91,8 @@ def parse_args(self, cmdline_args): group.add_argument('--list', action='store_true', help='list jobs') group.add_argument('--add', metavar='JOB', help='add job (key1=value1,key2=value2,...)') group.add_argument('--delete', metavar='JOB', help='delete job by location or index') + group.add_argument('--enable', metavar='JOB', help='enable job by location or index') + group.add_argument('--disable', metavar='JOB', help='disable job by location or index') group.add_argument('--change-location', metavar=('JOB', 'NEW_LOCATION'), nargs=2, help='change the location of an existing job by location or index') group.add_argument('--test-filter', metavar='JOB', help='test filter output of job by location or index') group.add_argument('--test-diff-filter', metavar='JOB',