Crates.io | fs-librarian |
lib.rs | fs-librarian |
version | |
source | src |
created_at | 2022-07-10 16:18:29.941442 |
updated_at | 2024-12-07 22:27:28.906573 |
description | Librarian runs pre-configured commands against a group of files that match a set of filters |
homepage | https://github.com/jasonrogena/librarian |
repository | https://github.com/jasonrogena/librarian |
max_upload_size | |
id | 623182 |
Cargo.toml error: | TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Librarian runs pre-configured commands against a group of files that match a set of filters. The group of files is called a library. Librarian can either search for files in a library or watch for when files in the library are created or updated.
To run Librarian once, where it exits after searching through a list of configured libraries, run:
fs-librarian single-shot path/to/config.toml
To make Librarian continually watch for when files in configured libraries are created or updated, run:
fs-librarian watch path/to/config.toml
You can use the pre-built binaries on the release page. They run as standalone binaries and don't require any prerequisite software installed on your machine.
On macOS, you can use Homebrew to install and update Librarian:
brew tap jasonrogena/librarian
brew install fs-librarian
To build Librarian, make sure you have rustup installed on your machine (installation instructions are here) then run:
make clean build
The binary target/release/fs-librarian
will be generated.
An example configuration file can be found here.
In the Librarian configuration file, define one or more "libraries" of files. A library is a set of files that match defined search filters. Supported search filters are:
For each of the defined libraries, provide a Tera template (whose syntax is based on Jinja2) of the command that should run when a file is found. The following variables are available to the template:
{{ file_path }}
: The path to the file that was found{{ mime_type }}
: The MIME type for the file that was found. Run the fs-librarian test mime <path to a file>
command to display the MIME types of files you are unsure about.The following configuration snippet defines a music library which watches for files inside the Downloads and /tmp directories that have MIME types matching the audio/.+
regex (e.g. audio/flac
and audio/ogg
). When an audio file is found, it is moved to the Music directory:
[libraries.music]
command = """
mv "{{ file_path }}" /home/jrogena/Music/
"""
[libraries.music.filter]
directories = [ "/home/jrogena/Downloads", "/tmp" ]
mime_type_regexes = [ "audio/.+" ]
The following configurations, related to filesystem watching, are available:
min_command_exec_freq
: Optional. The minimum frequency (in seconds) between running the configured command against a file. Useful in situations where a file is updated frequently but you don't want Librarian to run against the file as frequently as it is updated.The following snippet is an example filesystem watching configuration:
[fs_watch]
min_command_exec_freq = 60
Consider the following when using Librarian:
IN_CREATE
and IN_CLOSE_WRITE
on Linux) when a file is changed. You can avoid the pre-configured command from running more than once for every file update using the min_command_exec_freq
option.