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

Add changed environment variable #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode/
go.sum
CompileDaemon
60 changes: 39 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,75 @@ a file changed. Nothing more.

Usage:

$ ./CompileDaemon -directory=yourproject/
```bash
$ ./CompileDaemon -directory=yourproject/
```

## Installation

You can use the `go` tool to install `CompileDaemon`:

```bash
go get github.com/githubnemo/CompileDaemon
```

## Command Line Options

|Option | Default | Description|
|--------- | ----------- | -----------|
| | | **actions** |
|`-build=…` | go build | Specify the command to run when rebuilding is required.|
|`-command=…` | *none* | Specify the command to run after a succesful build. The default is to run nothing. This command is issued with the working directory set to -directory.|
| | | **file selection** |
|`-directory=…` | . | Which directory to watch.|
|`-recursive=…` | true | Recurse down the specified directory|
|`-exclude-dir=…` | none | Do not watch directories matching this glob pattern, e.g. ".git". You may have multiples of this flag.|
|`-exclude=…` | none | Exclude files matching this glob pattern, e.g. ".#*" ignores emacs temporary files. You may have multiples of this flag.|
|`-include=…` | none | Include files whose last path component matches this glob pattern. You may have multiples of this flag.|
|`-pattern=…` | (.+\\.go|.+\\.c)$ | A regular expression which matches the files to watch. The default watches *.go* and *.c* files.|
| | | **misc** |
|`-color=_` | false | Colorize the output of the daemon's status messages. |
|`-log-prefix=_` | true | Prefix all child process output with stdout/stderr labels and log timestamps. |
|`-graceful-kill=_`| false | On supported platforms, send the child process a SIGTERM to allow it to exit gracefully if possible. |
| Option | Default | Description |
| ------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | | **actions** |
| `-build=…` | go build | Specify the command to run when rebuilding is required. |
| `-command=…` | *none* | Specify the command to run after a succesful build. The default is to run nothing. This command is issued with the working directory set to -directory. |
| | | **file selection** |
| `-directory=…` | . | Which directory to watch. |
| `-recursive=…` | true | Recurse down the specified directory |
| `-exclude-dir=…` | none | Do not watch directories matching this glob pattern, e.g. ".git". You may have multiples of this flag. |
| `-exclude=…` | none | Exclude files matching this glob pattern, e.g. ".#*" ignores emacs temporary files. You may have multiples of this flag. |
| `-include=…` | none | Include files whose last path component matches this glob pattern. You may have multiples of this flag. |
| `-pattern=…` | (.+\\.go|.+\\.c)$ | A regular expression which matches the files to watch. The default watches *.go* and *.c* files. |
| | | **misc** |
| `-color=_` | false | Colorize the output of the daemon's status messages. |
| `-log-prefix=_` | true | Prefix all child process output with stdout/stderr labels and log timestamps. |
| `-graceful-kill=_` | false | On supported platforms, send the child process a SIGTERM to allow it to exit gracefully if possible. |

## Examples

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

$ CompileDaemon
```bash
$ 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"
```bash
$ 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.

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=".#*" …
```bash
$ 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"
```bash
$ 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

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

## Notes

Expand Down
Loading