Giter Club home page Giter Club logo

arelo's Introduction

Arelo - a simple auto reload utility

go test Go Report Card

Arelo executes the specified command and monitors the files under the target directory. When the file that matches the pattern has been modified, restart the command.

Features

  • Simple command line interface without config file
  • Monitoring file patterns are specified as glob
    • globstar (**; matches to zero or more directories) supported
    • can match the no extention filename
    • can match the hidden filename which starts with "."
  • Safely terminate child processes
  • Any command line tool can be executed
    • not only go project
    • can execute shell script
  • No unnesesary servers
    • no need to use local port unlike http server

Install

go install github.com/makiuchi-d/arelo@latest

Or, you can download the executable binaries from the release page.

To get a static-linked executable binary, build with CGO_ENABLED=0.

Quick start

Run this command in your Go project directory.

arelo -p '**/*.go' -i '**/.*' -i '**/*_test.go' -- go run .

Usage

Usage: arelo [OPTION]... -- COMMAND
Run the COMMAND and restart when a file matches the pattern has been modified.

Options:
  -d, --delay duration   duration to delay the restart of the command (default 1s)
  -f, --filter event     filter file system event (CREATE|WRITE|REMOVE|RENAME|CHMOD)
  -h, --help             display this message
  -i, --ignore glob      ignore pathname glob pattern
  -p, --pattern glob     trigger pathname glob pattern (default "**")
  -r, --restart          restart the command on exit
  -s, --signal signal    signal used to stop the command (default "SIGTERM")
  -t, --target path      observation target path (default "./")
  -v, --verbose          verbose output
  -V, --version          display version

Options

-t, --target path

Monitor file modifications under the path directory. The subdirectories are also monitored unless they match to the ignore patterns.

This option can be set multiple times.

The default value is the current directory ("./").

Note: This option can be file instead of directory, but arelo cannot follow modification after the file has been removed/renamed.

-p, --pattern glob

Restart command when the modified file is matched to this pattern.

The pattern is specified as an extended glob that supports {alt1,...}, ** like zsh or bash with globstar option. And note that the path delimiter is / even on Windows.

This option can set multiple times.

The default value ("**") is a pattern that matches any file in the target directories and their subdirectories.

-i, --ignore glob

Ignore the file or directory whose names is matched to this pattern.

This option takes precedence over the --pattern option.

This option can set multiple times.

-f, --filter event

Filter the filesystem event to ignore it.

The event can be CREATE, WRITE, REMOVE, RENAME or CHMOD.

This option can set multiple times.

-d, --delay duration

Delay the restart of the command from the detection of the pattern matched file modification. The detections within the delay are ignored.

The duration is specified as a number with a unit suffix ("ns", "us" (or "µs"), "ms", "s", "m", "h").

-s, --signal signal

This signal will be sent to stop the command on restart. The default signal is SIGTERM.

This option can be SIGHUP, SIGINT, SIGQUIT, SIGKILL, SIGUSR1, SIGUSR2, SIGWINCH or SIGTERM.

This option is not available on Windows.

-r, --restart

Automatically restart the command when it exits, similar to when the pattern matched file is modified.

-v, --verbose

Output logs verbosely.

-V, --version

Print version informatin.

-h, --help

Print usage.

Example

arelo -t ./src -t ./html -p '**/*.{go,html,yaml}' -i '**/.*' -- go run .

-t ./src -t ./html

Monitor files under the ./src or ./html directories.

-p '**/*.{go,html,yaml}'

Restart command when any *.go, *.html, *.yml file under the target, sub, and subsub... directories modified.

-i '**/.*'

Ignore files/directories whose name starts with '.'.

go run .

Command to run.

Similar projects

arelo's People

Contributors

makiuchi-d avatar yokogawa-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

arelo's Issues

error with long running command

I run tkinter loop in main.py, after one modification in main.py arelo will restart it process twice.

# arelo  -p '*.py'  -i '.*' -r  -v   -- .venv/bin/python main.py
2024/04/01 14:33:33 [ARELO] command:  [".venv/bin/python" "main.py"]
2024/04/01 14:33:33 [ARELO] targets:  ["./"]
2024/04/01 14:33:33 [ARELO] patterns: ["*.py"]
2024/04/01 14:33:33 [ARELO] ignores:  [".*"]
2024/04/01 14:33:33 [ARELO] filter:   [no events]
2024/04/01 14:33:33 [ARELO] delay:    1s
2024/04/01 14:33:33 [ARELO] signal:   SIGTERM
2024/04/01 14:33:33 [ARELO] restart:  true
2024/04/01 14:33:33 [ARELO] watching target: "."
2024/04/01 14:33:33 [ARELO] watching target: "__pycache__"
2024/04/01 14:33:33 [ARELO] watching target: "."
2024/04/01 14:33:33 [ARELO] start: .venv/bin/python main.py
2024/04/01 14:33:38 [ARELO] event: CHMOD "main.py"
2024/04/01 14:33:38 [ARELO] event: WRITE "main.py"
2024/04/01 14:33:38 [ARELO] triggered: "main.py"
2024/04/01 14:33:38 [ARELO] wait 1s
2024/04/01 14:33:39 [ARELO] command error: process canceled: exit status 1
2024/04/01 14:33:39 [ARELO] start: .venv/bin/python main.py
2024/04/01 14:33:39 [ARELO] event: CHMOD "main.py"
2024/04/01 14:33:39 [ARELO] triggered: "main.py"
2024/04/01 14:33:39 [ARELO] wait 1s
2024/04/01 14:33:40 [ARELO] command error: process canceled: exit status 1
2024/04/01 14:33:40 [ARELO] start: .venv/bin/python main.py

what happend on 2024/04/01 14:33:39 [ARELO] command error: process canceled: exit status 1
and why twice ?

thanks for your project.

Arm64 binaries

I really like this project.
Thank you for the development and continued maintenance.

It would be great to if binaries are provided for arm64 in GitHub Releases to make Go lang uncecessary for installation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.