Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 6.62 KB

README.md

File metadata and controls

69 lines (53 loc) · 6.62 KB

fsriev - a file watch utility

GitHub release (latest SemVer) GitHub top language GitHub GitHub Workflow Status GitHub issues

fsriev is a simple but highly customizable file watcher for Windows and Linux.

fsriev will watch a folder and its subfolders for file changes, and it'll trigger your set of commands when the change is detected. Multiple directories can be watched at once, with each directory having its own set of rules and commands to execute.
fsriev uses ASP.NET Core's Configuration system which allows for a large variety of configuration approaches without using command arguments - although these are possible to use, too! By default, fsriev will use a settings file.

Download

See releases to download the latest version for your machine.
Alternatively, build the project yourself.

Configuration

The primary means of configuring fsriev is through appsettings.json file.

Workers Config

Each directory to watch needs to be added as a new JSON object to Watchers array.

Property Name Type Required? Default Value Description
Name string No Unnamed Watcher The name of the watcher that will appear in log messages. Useful to recognize watcher when running multiple.
Enabled bool No true Whether the watcher is enabled. Allows disabling the watcher without removing it from the configuration.
FolderPath string Yes Path of the folder to watch. Can contain environment variables.
FileFilters array of strings No * File name filters that need to match in order for commands to be executed. Pro-tip: this can be a file name to watch a specific file only.
Recursive bool No true Whether watcher should watch for file changes in subfolders.
SkipWhenBusy bool No true Watcher might receive multiple events at once. This switch controls if watcher should ignore them while already processing one.
NotifyFilters string/int No LastWrite,FileName Flags that will be checked to determine if the file has changed. See NotifyFilters for a list of valid values.
Exclusions array of strings No Filters of ignored files. Useful for example when you want to ignore VS temporary files (*~*.tmp) or minified JS outputs (*.min.*).
WorkingDirectory string No Value of FolderPath Working directory that will be used when executing the commands. Can contain environment variables.
ShowCommandOutput bool No true Whether output of ran commands should be displayed.
Commands array of strings No Commands to execute when a file change has been detected. Commands are executed in order, regardless if previous command executed correctly or not. Note: if no command is added, a warning will be output to logs.

Other Config

There are a few properties that can be configured outside of Watchers array.

Property Name Type Required? Default Value Description
CommandOutputMode string/int No Console How command output should be displayed. Supported values are Console, Log. If you run fsriev manually, in terminal etc, "Console" is recommended. If you depend on log files to see the output, use "Log". Note: you can technically use both at once (Console,Log), but it is not recommended. This might be useful if logging to console is disabled in Logging configuration.
CommandOutputLevel string/int No Information Only applicable when CommandOutputMode is set to "Log". Sets the level that command output will be logged as. Valid values are "Verbose", "Debug", "Information", "Warning", "Error" and "Fatal". Note: this applies only to STDOUT. STDERR will always be logged as Error.
LogsDirectory string No null Changes logs directory. Can use system's environment variables. If not set, will use default value (see below). Note: if you create logsettings.json, this value will be ignored.

Logging

By default the application will log to terminal window and to %PROGRAMDATA%/TehGM/fsriev/logs on Windows and /usr/share/TehGM/fsriev/logs on Linux.
If you wish to simply change the folder, you can set it using LogsDirectory property in your config. You can use environment variables.

Note: Currently changing LogsDirectory when fsriev is running will have no effect, and restart is required.

Advanced

Application will use default log settings (log to console and file, keep max 30 difles of max 1MB each, etc). If you wish to further customize your logging settings, you can create a new logsettings.json file in fsriev directory. See here for example of how to configure your logsettings.json file.
See Serilog.Settings.Configuration for more info.

Note: if logsettings.json file exists, application will completely ignore its default configuration as well as LogsDirectory property. This is to allow full customization of log config.

Important Notes

  • Do NOT close fsriev by pressing X if any of the commands is still running. Due to terminal limitations, fsriev will not have any chance to kill command process.
    Instead, send shut down signal to fsriev - for example by pressing Ctrl+C. Doing so will notify fsriev to kill commands before exiting.
  • Currently, the default application config contains example configuration. It will most likely log an error due to directory not existing. Simply update your configuration to solve this.

Building

  1. Install .NET 5 SDK.
  2. Clone the repository.
  3. Build the project.

Contributing

If you spot a bug or want to suggest a feature or improvement, feel free to open a new Issue.

License

Copyright (c) 2021 TehGM

Licensed under Mozilla Public License 2.0 (MPL-2.0).