Quick Start¶
This guide will help you get started with Blink quickly. We'll cover the basics of watching a directory for changes and receiving events.
Basic Usage¶
The simplest way to use Blink is to watch the current directory:
This will start Blink with default settings, watching the current directory for changes and serving events on http://localhost:12345/events.
You should see output similar to:
Blink File System Watcher
-------------------------
Watching directory: .
Serving events at: http://localhost:12345/events
Refresh duration: 100ms
Verbose mode: false
Using 8 CPUs
Press Ctrl+C to exit
Making Changes¶
With Blink running, open another terminal and make some changes to files in the watched directory:
# Create a new file
touch test.txt
# Modify the file
echo "Hello, Blink!" > test.txt
# Remove the file
rm test.txt
If you have verbose mode enabled (blink --verbose), you'll see these events logged in the Blink terminal.
Receiving Events¶
To receive events from Blink, you need to connect to the event stream. Here are examples in different languages:
package main
import (
"bufio"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:12345/events")
if err != nil {
panic(err)
}
defer resp.Body.Close()
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
line := scanner.Text()
if len(line) > 0 && line[:5] == "data:" {
fmt.Println("File changed:", line[6:])
}
}
}
Common Options¶
Here are some common options you might want to use:
# Watch a specific directory
blink --path /path/to/watch
# Enable verbose logging
blink --verbose
# Use a different port
blink --event-addr :8080
# Only watch specific file types
blink --include "*.js,*.css,*.html"
# Ignore specific directories
blink --exclude "node_modules,dist"
# Send webhooks when files change
blink --webhook-url "https://example.com/webhook"
Next Steps¶
Now that you've seen the basics of Blink, you can:
- Learn about Configuration options
- Explore Event Filtering
- Set up Webhooks
- Check out the Command Line interface
- Use Blink as a Library in your Go projects