From 7288f128470431775e35de43a92222792ba7ce05 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 5 May 2021 21:31:45 +0300 Subject: [PATCH] v help: add `v help watch`, rename -watch in `v help` too --- cmd/v/help/default.txt | 8 +++++--- cmd/v/help/watch.txt | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 cmd/v/help/watch.txt diff --git a/cmd/v/help/default.txt b/cmd/v/help/default.txt index 80492e9a3c..b3cc93426b 100644 --- a/cmd/v/help/default.txt +++ b/cmd/v/help/default.txt @@ -9,8 +9,9 @@ Examples: v -cg run hello.v Same as above, but make debugging easier (in case your program crashes). v -o h.c hello.v Translate `hello.v` to `h.c`. Do not compile further. - v -watch hello.v Re-compiles over and over the same compilation, when a source change is detected. - v -watch run file.v Re-runs over and over the same file.v, when a source change is detected. + v watch hello.v Re-does the same compilation, when a source code change is detected. + The program is only compiled, not run. + v watch run hello.v Re-runs the same `hello.v` file, when a source code change is detected. V supports the following commands: * New project scaffolding: @@ -25,6 +26,7 @@ V supports the following commands: doc Generate the documentation for a V module. vlib-docs Generate and open the documentation of all the vlib modules. repl Run the REPL. + watch Re-compile/re-run a source file, each time it is changed. * Installation/self updating: symlink Create a symbolic link for V. @@ -52,4 +54,4 @@ Use "v help " for more information about a command, example: `v help bu Use "v help other" to see less frequently used commands. Note: Help is required to write more help topics. -Only build, new, init, doc, fmt, vet, run, test, search, install, remove, update, bin2v, check-md are properly documented currently. +Only build, new, init, doc, fmt, vet, run, test, watch, search, install, remove, update, bin2v, check-md are properly documented currently. diff --git a/cmd/v/help/watch.txt b/cmd/v/help/watch.txt new file mode 100644 index 0000000000..f3c3e0a0cf --- /dev/null +++ b/cmd/v/help/watch.txt @@ -0,0 +1,18 @@ +v watch [--clear] [--ignore .db] [--add /path/to/a/file.v] [other V options] [run] program.v + +Description: +`v watch` collects all .v files needed for a compilation, then when +any of the .v source files changes, it re-runs the compilation. + +Options: + -c, --clear Clears the terminal before each re-run. + + -a, --add Add more files to be watched. + Useful with `v watch -add=feature.v run cmd/v feature.v`, + when you want to change *both* the V compiler, + and the `feature.v` file. + + -i, --ignore Ignore files having these extensions. + Useful with `v watch -ignore=.db run vwebserver.v`, + if your `vwebserver` writes to an sqlite.db file in the + same folder.