Code Monkey home page Code Monkey logo

rorshach's Introduction

License: MIT Build

Rorshach rorschach.gif

A watchman for your directories. Rorshach allows you to watch your directories for changes and trigger certain commands when these events occur.

Installlation

At the moment the only way to install is from crates.io (https://crates.io/crates/rorshach). Run cargo install rorshach to install it on a linux machine.

Usage

  • ./rorshach -f <dir> [-config <config_path>] [-t <seconds_to_wait_before_reload>]

The default config file lies at ~/.rorshach.conf

Config

Configuration file is a tab separated values (TSV) file, and has the following format:

EVENT  PATTERN   ACTION
...     ...       ...

Sample Configuration File

Please ensure you have physical TAB characters as delimiters. If you are using vim, you can use :set list to show invisible characters. It would look like this:

image

Otherwise, you will receive an error during start.

Events

EVENTS can be CREATE, DELETE RENAME or MODIFY. Each event is trigger when a file in the directory being watched is CREATED, DELETED, MODIFIED or RENAMED respectively. PATTERNS are patterns to match the files in a directory. Example *.cpp matches all the C++ files in a directory. ACTIONS are commands that can be executed when a EVENT occures

There are following environment variable available while executing an action, they are :- {FULLPATH} - Full path to the file, {BASEDIR} - Path to the directory that rorshach is watching {NEWFULLPATH} - New Path to the file, when a file is renamed else empty.

Examples

CREATE  *   echo " New file named ${FULLPATH} created"

The above will print a line of the form New file named <file-name> created every time a new file is created.

MODIFY  *.cpp   g++ ${FULLPATH} {BASEDIR}/test

Whenver a change is detected in a c++ file, rorshach will compile that file and create an executable named test in the base directory

TODO

  • Add more events to listen like Rename
  • Support execution of a chain of commands for a single event
  • Move Command Line passing to a different struct
  • Add a threadpool to execute each task once an event is spawned
  • Add a pub-sub mechanism for events
  • Add Tests?
  • Move parse_rules to an enclosing struct
  • Use log create for logging.
  • Provide better messages for errors.
  • Add a pub sub mechanism to listening to events and consuming them

rorshach's People

Contributors

basaran avatar sam09 avatar suyashb95 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

Watchers

 avatar  avatar

rorshach's Issues

config file tab

Hello, perhaps you should mention in the readme that a "tab" character is required for the config file to be parsed. Otherwise it throws of a generic "you need to use one of the .." error without mentioning the issue. Thank you for the tool :)

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.