githubnemo / CompileDaemon

Very simple compile daemon for Go
BSD 2-Clause "Simplified" License
1.61k stars 153 forks source link

Add changed environment variable #39

Open mvochoa opened 4 years ago

mvochoa commented 4 years ago

An environment variable was added with the file path that was modified, so that the user can use it in the commands.

$ CompileDaemon --build="go build \$FILE"

In addition, the help message was modified:

$ CompileDaemon --help
Copyright (c) 2013, Marian Tietz

Examples

In its simplest form, the defaults will do. With the current working directory set
to the source directory you can simply…

    $ CompileDaemon

… and it will recompile your code whenever you save a source file.

If you want it to also run your program each time it builds you might add…

    $ CompileDaemon -command="./MyProgram -my-options"

… and it will also keep a copy of your program running. Killing the old one and
starting a new one each time you build. For advanced usage you can also supply
the changed file to the command by doing…

    $ CompileDaemon -command="./MyProgram -my-options %[1]s"

…but note that this will not be set on the first start.

You may find that you need to exclude some directories and files from
monitoring, such as a .git repository or emacs temporary files…

    $ CompileDaemon -exclude-dir=.git -exclude=".#*"

If you want to monitor files other than .go and .c files you might…

    $ CompileDaemon -include=Makefile -include="*.less" -include="*.tmpl"

If you only need to work with the file that changes, the $FILE variable has the modified file path

    $ CompileDaemon --build="go build \$FILE"

Usage of CompileDaemon:

  -build string
        Command to rebuild after changes (default "go build")
  -build-dir string
        Directory to run build command in.  Defaults to directory
  -color
        Colorize output for CompileDaemon status messages
  -command string
        Command to run and restart after build
  -command-stop
        Stop command before building
  -directory string
        Directory to watch for changes (default ".")
  -exclude value
         Don't watch files matching this name
  -exclude-dir value
         Don't watch directories matching this name
  -graceful-kill
        Gracefully attempt to kill the child process by sending a SIGTERM first
  -graceful-timeout uint
        Duration (in seconds) to wait for graceful kill to complete (default 3)
  -include value
         Watch files matching this name
  -log-prefix
        Print log timestamps and subprocess stderr/stdout output (default true)
  -pattern string
        Pattern of watched files (default "(.+\\.go|.+\\.c)$")
  -recursive
        Watch all dirs. recursively (default true)
  -run-dir string
        Directory to run command in.  Defaults to directory
  -verbose
        Be verbose about which directories are watched.
githubnemo commented 4 years ago

Hi, thanks for your PR and sorry for the wait.

This seems to be a sensible addition but it is quite hard to review the relevant portions of the change among all the other changes. I will take a look, though.