{"id":16334570,"url":"https://github.com/pta2002/gleam-filespy","last_synced_at":"2025-07-13T16:32:53.292Z","repository":{"id":202766211,"uuid":"708087483","full_name":"pta2002/gleam-filespy","owner":"pta2002","description":"Get notified of filesystem changes in Gleam","archived":false,"fork":false,"pushed_at":"2024-06-12T09:07:34.000Z","size":27,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-26T19:27:39.654Z","etag":null,"topics":["gleam"],"latest_commit_sha":null,"homepage":"","language":"Gleam","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pta2002.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-21T13:42:55.000Z","updated_at":"2024-10-08T11:55:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbbea3b2-2e58-416b-97bc-a84a0987a962","html_url":"https://github.com/pta2002/gleam-filespy","commit_stats":null,"previous_names":["pta2002/gleam-filespy"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pta2002%2Fgleam-filespy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pta2002%2Fgleam-filespy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pta2002%2Fgleam-filespy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pta2002%2Fgleam-filespy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pta2002","download_url":"https://codeload.github.com/pta2002/gleam-filespy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239358667,"owners_count":19625526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gleam"],"created_at":"2024-10-10T23:38:46.288Z","updated_at":"2025-02-17T20:22:06.019Z","avatar_url":"https://github.com/pta2002.png","language":"Gleam","funding_links":[],"categories":[],"sub_categories":[],"readme":"# filespy\n\n[![Package Version](https://img.shields.io/hexpm/v/filespy)](https://hex.pm/packages/filespy)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/filespy/)\n\nFilespy is a small library and versatile library that allows you to watch for filesystem events from Gleam! It's a type-safe wrapper around the erlang [FS](https://github.com/5HT/fs) library.\n\n## Quick start\n\nAdd the library to your requirements with `gleam add`:\n\n```sh\ngleam add filespy\n```\n\n**Note**: If you use Linux or a BSD, you need to install `inotify-tools`!\n\n## Usage\n\nThe library is configured via a simple builder:\n\n```gleam\nimport filespy\nimport gleam/io\nimport gleam/erlang/process\n\nfn main() {\n    let _res = filespy.new()   // Create the builder\n    |\u003e filespy.add_dir(\".\")    // Watch the current directory\n    |\u003e filespy.add_dir(\"/mnt\") // Watch the /mnt directory\n    |\u003e filespy.set_handler(fn (path, event) {\n        // This callback will be run every time a filesystem event is detected\n        // in the specified directories\n        io.debug(#(path, event))\n        Nil\n    })\n    |\u003e filespy.start()        // Start the watcher!\n\n    process.sleep_forever()\n}\n```\n\nIf you want to, you can also go lower level, and configure the underlying actor:\n\n```gleam\nimport filespy\nimport gleam/io\n\nfn main() {\n    let _res = filespy.new()        // Create the builder\n    |\u003e filespy.add_dir(\".\")         // Watch the current directory\n    |\u003e filespy.add_dir(\"/mnt\")      // Watch the /mnt directory\n    |\u003e filespy.set_initial_state(0) // Initial state for the actor, this is required!\n    |\u003e filespy.set_actor_handler(fn (message, state) {\n        // This callback will be run every time a filesystem event is detected\n        // in the specified directories\n\n        // In the actor handler, multiple events might be sent at once.\n        let filespy.Change(path: path, events: events) = message\n        io.debug(#(path, events, state))\n        \n        actor.continue(state + 1)\n    })\n    |\u003e filespy.start()              // Start the watcher!\n\n    process.sleep_forever()\n}\n```\n\nYou can go even lower level, and get the actor start spec to configure it yourself:\n\n```gleam\nimport filespy\nimport gleam/io\n\nfn main() {\n    let start_spec = filespy.new()  // Create the builder\n    |\u003e filespy.add_dir(\".\")         // Watch the current directory\n    |\u003e filespy.add_dir(\"/mnt\")      // Watch the /mnt directory\n    |\u003e filespy.set_initial_state(0) // Initial state for the actor, this is required!\n    |\u003e filespy.set_actor_handler(fn (message, state) {\n        // This callback will be run every time a filesystem event is detected\n        // in the specified directories\n\n        // In the actor handler, multiple events might be sent at once.\n        let filespy.Change(path: path, events: events) = message\n        io.debug(#(path, events, state))\n        \n        actor.continue(state + 1)\n    })\n    |\u003e filespy.spec()               // Get the spec\n\n    actor.start_spec(start_spec)\n\n    process.sleep_forever()\n}\n```\n\n## Documentation\nIf you have any more questions, check out the [documentation](https://hexdocs.pm/filespy)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpta2002%2Fgleam-filespy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpta2002%2Fgleam-filespy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpta2002%2Fgleam-filespy/lists"}