Skip to content
/ fw Public

A very simple tool to watch files and execute commands on transitions.

License

Notifications You must be signed in to change notification settings

shellshape/fw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fw

A very simple tool to watch files and execute commands on transitions.

You can download the pre-built binaries from the Releases page.

If there is no binary for your system configuration available, you can also use cargo to install the application.

cargo install --git https://github.com/zekrotja/fw fw

Why?

This tool is mostly purpose built to simplify and speed up some task during my development at work by restarting services when re-building modules. But still the target of the project is to make it as general purpose as possible, so that other automation tasks can be realized using this tool. Feel free to contribute ideas and bugs via the issues or by creating a pull request.

Configuration

Configuration can be provided as TOML, YML or JSON file either in the current working directory as fw.* or in the users home config directory, which maps to the following directories depending on the OS.

  • Linux: $HOME/.config/fw/config.*
  • macOS: $HOME/Library/Application Support/de.zekro.fw/config.*
  • Windows: %APPDATA%/zekro/fw/config.*

You can also pass a configuration via the --config parameter.

Following, you can see an example configuration in YML format.

# The interval in which files will be checked
# for changes in milliseconds.
# optional
# default: 1000
check_interval_ms: 1000

# Conbinations of targets with commands
# which are executed for each target if
# it matches.
# required
actions:
  # ID of the action
  myaction:
    # Define commands that shall run on the tool
    # startup for this action. This overwrites
    # run_commands_on_startup to true.
    startup_commands:
      - "killall -s TERM myapp"
    # Set this to true to run the defined action
    # commands on startup of the tool.
    run_commands_on_startup: true
    # List of files to be watched and
    # transitions which will trigger the
    # command execution.
    # required
    targets:
      - "some/path/file"
        # The file path of the watched file.
        # required
      - path: "another/path/file"
        # The list of transitions on the file
        # triggering the command execution.
        # optional
        # default: all transitions
        transitions:
          - "created"
          - "modified"
          - "deleted"
      - path: "/last/path/file"
    commands:
      - 'sh -c "echo hello world!"' 
        # The command to be executed.
        # required
      - cmd: "cargo build"
        # The directory in which the command
        # will be executed.
        # optional
        # default: "./"
        cwd: "/dir/to/app"
        # Defaultly, the next command in line
        # will only be executed after the previous
        # one has resulted. When this is set to
        # true though, the next command is
        # executed immediately after calling 
        # the command and the current command
        # is executed in the background.
        # optional
        # default: false
        async: true