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

[watchmedo] Fix broken parsing of boolean arguments #887

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.rst
Expand Up @@ -10,7 +10,8 @@ Changelog

- Fix adding failed emitters on observer schedule. (`#872 <https://github.com/gorakhargosh/watchdog/issues/872>`_)
- [watchmedo] Fix broken parsing of ``--kill-after`` argument for the ``auto-restart`` command. (`#870 <https://github.com/gorakhargosh/watchdog/issues/870>`_)
- Thanks to our beloved contributors: @taleinat, @kianmeng, @palfrey, @IlayRosenberg
- [watchmedo] Fix broken parsing of boolean arguments. (`#855 <https://github.com/gorakhargosh/watchdog/issues/855>`_)
- Thanks to our beloved contributors: @taleinat, @kianmeng, @palfrey, @IlayRosenberg, @BoboTiG

2.1.7
~~~~~
Expand Down
37 changes: 16 additions & 21 deletions src/watchdog/watchmedo.py
Expand Up @@ -213,22 +213,23 @@ def schedule_tricks(observer, tricks, pathname, recursive):
type=float,
help='Use this as the polling interval/blocking timeout (in seconds).'),
argument('--recursive',
action='store_true',
default=True,
help='Recursively monitor paths.'),
argument('--debug-force-polling',
default=False,
action='store_true',
help='[debug] Forces polling.'),
argument('--debug-force-kqueue',
default=False,
action='store_true',
help='[debug] Forces BSD kqueue(2).'),
argument('--debug-force-winapi',
default=False,
action='store_true',
help='[debug] Forces Windows API.'),
argument('--debug-force-fsevents',
default=False,
action='store_true',
help='[debug] Forces macOS FSEvents.'),
argument('--debug-force-inotify',
default=False,
action='store_true',
help='[debug] Forces Linux inotify(7).')],
cmd_aliases=['tricks'])
def tricks_from(args):
Expand Down Expand Up @@ -302,7 +303,7 @@ def tricks_from(args):
argument('-a',
'--append-only',
dest='append_only',
default=False,
action='store_true',
help='''
If --append-to-file is not specified, produces output for
appending instead of a complete tricks YAML file.''')],
Expand Down Expand Up @@ -357,13 +358,11 @@ def tricks_generate_yaml(args):
argument('-D',
'--ignore-directories',
dest='ignore_directories',
default=False,
action='store_true',
help='Ignores events for directories.'),
argument('-R',
'--recursive',
dest='recursive',
default=False,
action='store_true',
help='Monitors the directories recursively.'),
argument('--interval',
Expand All @@ -373,22 +372,22 @@ def tricks_generate_yaml(args):
type=float,
help='Use this as the polling interval/blocking timeout.'),
argument('--trace',
default=False,
action='store_true',
help='Dumps complete dispatching trace.'),
argument('--debug-force-polling',
default=False,
action='store_true',
help='[debug] Forces polling.'),
argument('--debug-force-kqueue',
default=False,
action='store_true',
help='[debug] Forces BSD kqueue(2).'),
argument('--debug-force-winapi',
default=False,
action='store_true',
help='[debug] Forces Windows API.'),
argument('--debug-force-fsevents',
default=False,
action='store_true',
help='[debug] Forces macOS FSEvents.'),
argument('--debug-force-inotify',
default=False,
action='store_true',
help='[debug] Forces Linux inotify(7).')])
def log(args):
"""
Expand Down Expand Up @@ -472,7 +471,6 @@ def log(args):
argument('-R',
'--recursive',
dest='recursive',
default=False,
action='store_true',
help='Monitors the directories recursively.'),
argument('--interval',
Expand All @@ -484,16 +482,14 @@ def log(args):
argument('-w', '--wait',
dest='wait_for_process',
action='store_true',
default=False,
help='Wait for process to finish to avoid multiple simultaneous instances.'),
argument('-W', '--drop',
dest='drop_during_process',
action='store_true',
default=False,
help='Ignore events that occur while command is still being'
' executed to avoid multiple simultaneous instances.'),
argument('--debug-force-polling',
default=False,
action='store_true',
help='[debug] Forces polling.')])
def shell_command(args):
"""
Expand Down Expand Up @@ -535,7 +531,7 @@ def shell_command(args):
argument('-d',
'--directory',
dest='directories',
metavar='directory',
metavar='DIRECTORY',
action='append',
help='Directory to watch. Use another -d or --directory option '
'for each directory.'),
Expand All @@ -560,7 +556,6 @@ def shell_command(args):
argument('-R',
'--recursive',
dest='recursive',
default=False,
action='store_true',
help='Monitors the directories recursively.'),
argument('--interval',
Expand All @@ -574,7 +569,7 @@ def shell_command(args):
default='SIGINT',
help='Stop the subprocess with this signal (default SIGINT).'),
argument('--debug-force-polling',
default=False,
action='store_true',
help='[debug] Forces polling.'),
argument('--kill-after',
dest='kill_after',
Expand Down
4 changes: 3 additions & 1 deletion tests/test_0_watchmedo.py
Expand Up @@ -75,10 +75,12 @@ def test_kill_auto_restart(tmpdir, capfd):


def test_auto_restart_arg_parsing_basic():
args = watchmedo.cli.parse_args(["auto-restart", "-d", ".", "cmd"])
args = watchmedo.cli.parse_args(["auto-restart", "-d", ".", "--recursive", "--debug-force-polling", "cmd"])
assert args.func is watchmedo.auto_restart
assert args.command == "cmd"
assert args.directories == ["."]
assert args.recursive
assert args.debug_force_polling


def test_auto_restart_arg_parsing_kill_after():
Expand Down