pw_watch: Automatically restart builds by default
Change-Id: I8ac1c4c7a29cb39a52f7ad599e17b8adaa639949
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/41161
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/pw_watch/docs.rst b/pw_watch/docs.rst
index 6e0824a..ad4def6 100644
--- a/pw_watch/docs.rst
+++ b/pw_watch/docs.rst
@@ -50,7 +50,9 @@
The ``--exclude_list`` argument can be used to exclude directories from being
watched. This decreases the number of files monitored with inotify in Linux.
-While running ``pw watch``, press enter to immediately trigger a rebuild.
+By default, ``pw watch`` automatically restarts an ongoing build when files
+change. This can be disabled with the ``--no-restart`` option. While running
+``pw watch``, you may also press enter to immediately restart a build.
Unit Test Integration
=====================
diff --git a/pw_watch/py/pw_watch/watch.py b/pw_watch/py/pw_watch/watch.py
index 30d221f..c7269e7 100755
--- a/pw_watch/py/pw_watch/watch.py
+++ b/pw_watch/py/pw_watch/watch.py
@@ -141,7 +141,7 @@
ignore_patterns: Sequence[str] = (),
build_commands: Sequence[BuildCommand] = (),
charset: WatchCharset = _ASCII_CHARSET,
- restart: bool = False,
+ restart: bool = True,
):
super().__init__()
@@ -350,9 +350,10 @@
type=Path,
help='directories to ignore during pw watch',
default=[])
- parser.add_argument('--restart',
- action='store_true',
- help='restart an ongoing build if files change')
+ parser.add_argument('--no-restart',
+ dest='restart',
+ action='store_false',
+ help='do not restart ongoing builds if files change')
parser.add_argument(
'default_build_targets',
nargs='*',