fgof-watch Public
fgof-watch
Portable file watching helpers for modern Fortran tools.
fgof-watch is intended to be a small, standalone library for directory and file watching in shells, editors, live-reload tools, sync utilities, and developer loops.
It is part of the FortranGoingOnForty lib-modules catalog, but it is intended to stand on its own as a normal fpm package.
Current v1 target:
- high-level watch-session API
- portable polling backend as a dependable baseline
- normalized events for create, modify, remove, and move
- debounce and filtering hooks that app authors can actually use
- clean boundaries with
fgof-processand futurefgof-devloop
Future scope:
- native backends once the public API is stable
- richer event coalescing and ignore-rule helpers
- higher-level dev-loop orchestration in companion packages
Status
Polling-first v0.1.0 candidate is in place.
Implemented today:
- public
fgof_watchandfgof_watch_typesmodules - polling-backed
watch_session,watch_options, andwatch_eventtypes - initialization, reset, and batch polling helpers
- normalized create, modify, remove, and move events
- recursive and nonrecursive polling behavior
- hidden-path filtering and ignored-prefix filtering
- optional suppression of directory create or remove noise
- debounce-based quieting for bursty paths
- snapshot-failure reporting without false remove storms
- ignored and hidden subtrees pruned before deep traversal
- literal path bytes preserved across snapshot transport, including tabs and newlines
- smoke-test and change-detection coverage with CI wiring
Still to implement:
- native backend strategy
- further event coalescing and policy helpers
Why Use It
- file watching is still one of the biggest remaining tooling gaps in Fortran
- app authors want a reusable library surface, not only standalone watcher tools
- it should compose naturally with
fgof-process, futurefgof-devloop, editors, and live-reload workflows
Public API Shape
Primary modules:
fgof_watchfgof_watch_types
Public types:
watch_eventwatch_entrywatch_optionswatch_session
Current public procedures:
clear_ignore_prefixesinit_watchpoll_watchreset_watchset_ignore_prefixes
Event constants:
FGOF_WATCH_EVT_NONEFGOF_WATCH_EVT_CREATEDFGOF_WATCH_EVT_MODIFIEDFGOF_WATCH_EVT_REMOVEDFGOF_WATCH_EVT_MOVED
Error constants:
FGOF_WATCH_ERR_NONEFGOF_WATCH_ERR_SNAPSHOT_FAILED
Quick Start
program demo_watch
use fgof_watch, only : init_watch, poll_watch, set_ignore_prefixes
use fgof_watch_types, only : watch_event, watch_options, watch_session
implicit none
type(watch_event), allocatable :: events(:)
type(watch_options) :: options
type(watch_session) :: session
options%debounce_polls = 1
options%ignore_hidden = .true.
options%emit_directory_events = .false.
call set_ignore_prefixes(options, [character(len=9) :: "src/.git"])
call init_watch(session, "src", options)
events = poll_watch(session)
print "(I0)", size(events)
end program demo_watch
Build And Test
fpm test
That is the baseline verification command locally and in CI.
Supported Platforms
- macOS
- Linux
Boundaries
- intended to stay independently versioned and releasable
- focused on reusable watch primitives, not a full dev-loop tool
- polling will be the first dependable backend; native backends can come later without changing the high-level surface
- the current polling backend reports event batches and suppresses directory-only metadata churn, so nested file activity is the signal that rises to the top
- current shaping controls include
debounce_polls,ignore_hidden, ignored path prefixes, andemit_directory_events - snapshot read failures preserve the previous watch state, emit no events for that poll, and surface detail through
watch_session%last_error_codeandwatch_session%last_error_message - hidden and ignored prefixes are pruned during snapshot collection, so excluded subtrees do not need to be fully scanned first
License
MIT
View source
| 1 | # fgof-watch |
| 2 | |
| 3 | [](https://github.com/FortranGoingOnForty/fgof-watch/actions/workflows/ci.yml) |
| 4 | |
| 5 | Portable file watching helpers for modern Fortran tools. |
| 6 | |
| 7 | `fgof-watch` is intended to be a small, standalone library for directory and file watching in shells, editors, live-reload tools, sync utilities, and developer loops. |
| 8 | |
| 9 | It is part of the [FortranGoingOnForty lib-modules](https://github.com/FortranGoingOnForty/lib-modules) catalog, but it is intended to stand on its own as a normal `fpm` package. |
| 10 | |
| 11 | Current v1 target: |
| 12 | |
| 13 | - high-level watch-session API |
| 14 | - portable polling backend as a dependable baseline |
| 15 | - normalized events for create, modify, remove, and move |
| 16 | - debounce and filtering hooks that app authors can actually use |
| 17 | - clean boundaries with `fgof-process` and future `fgof-devloop` |
| 18 | |
| 19 | Future scope: |
| 20 | |
| 21 | - native backends once the public API is stable |
| 22 | - richer event coalescing and ignore-rule helpers |
| 23 | - higher-level dev-loop orchestration in companion packages |
| 24 | |
| 25 | ## Status |
| 26 | |
| 27 | Polling-first `v0.1.0` candidate is in place. |
| 28 | |
| 29 | Implemented today: |
| 30 | |
| 31 | - public `fgof_watch` and `fgof_watch_types` modules |
| 32 | - polling-backed `watch_session`, `watch_options`, and `watch_event` types |
| 33 | - initialization, reset, and batch polling helpers |
| 34 | - normalized create, modify, remove, and move events |
| 35 | - recursive and nonrecursive polling behavior |
| 36 | - hidden-path filtering and ignored-prefix filtering |
| 37 | - optional suppression of directory create or remove noise |
| 38 | - debounce-based quieting for bursty paths |
| 39 | - snapshot-failure reporting without false remove storms |
| 40 | - ignored and hidden subtrees pruned before deep traversal |
| 41 | - literal path bytes preserved across snapshot transport, including tabs and newlines |
| 42 | - smoke-test and change-detection coverage with CI wiring |
| 43 | |
| 44 | Still to implement: |
| 45 | |
| 46 | - native backend strategy |
| 47 | - further event coalescing and policy helpers |
| 48 | |
| 49 | ## Why Use It |
| 50 | |
| 51 | - file watching is still one of the biggest remaining tooling gaps in Fortran |
| 52 | - app authors want a reusable library surface, not only standalone watcher tools |
| 53 | - it should compose naturally with `fgof-process`, future `fgof-devloop`, editors, and live-reload workflows |
| 54 | |
| 55 | ## Public API Shape |
| 56 | |
| 57 | Primary modules: |
| 58 | |
| 59 | - `fgof_watch` |
| 60 | - `fgof_watch_types` |
| 61 | |
| 62 | Public types: |
| 63 | |
| 64 | - `watch_event` |
| 65 | - `watch_entry` |
| 66 | - `watch_options` |
| 67 | - `watch_session` |
| 68 | |
| 69 | Current public procedures: |
| 70 | |
| 71 | - `clear_ignore_prefixes` |
| 72 | - `init_watch` |
| 73 | - `poll_watch` |
| 74 | - `reset_watch` |
| 75 | - `set_ignore_prefixes` |
| 76 | |
| 77 | Event constants: |
| 78 | |
| 79 | - `FGOF_WATCH_EVT_NONE` |
| 80 | - `FGOF_WATCH_EVT_CREATED` |
| 81 | - `FGOF_WATCH_EVT_MODIFIED` |
| 82 | - `FGOF_WATCH_EVT_REMOVED` |
| 83 | - `FGOF_WATCH_EVT_MOVED` |
| 84 | |
| 85 | Error constants: |
| 86 | |
| 87 | - `FGOF_WATCH_ERR_NONE` |
| 88 | - `FGOF_WATCH_ERR_SNAPSHOT_FAILED` |
| 89 | |
| 90 | ## Quick Start |
| 91 | |
| 92 | ```fortran |
| 93 | program demo_watch |
| 94 | use fgof_watch, only : init_watch, poll_watch, set_ignore_prefixes |
| 95 | use fgof_watch_types, only : watch_event, watch_options, watch_session |
| 96 | implicit none |
| 97 | |
| 98 | type(watch_event), allocatable :: events(:) |
| 99 | type(watch_options) :: options |
| 100 | type(watch_session) :: session |
| 101 | |
| 102 | options%debounce_polls = 1 |
| 103 | options%ignore_hidden = .true. |
| 104 | options%emit_directory_events = .false. |
| 105 | call set_ignore_prefixes(options, [character(len=9) :: "src/.git"]) |
| 106 | call init_watch(session, "src", options) |
| 107 | events = poll_watch(session) |
| 108 | print "(I0)", size(events) |
| 109 | end program demo_watch |
| 110 | ``` |
| 111 | |
| 112 | ## Build And Test |
| 113 | |
| 114 | ```bash |
| 115 | fpm test |
| 116 | ``` |
| 117 | |
| 118 | That is the baseline verification command locally and in CI. |
| 119 | |
| 120 | ## Supported Platforms |
| 121 | |
| 122 | - macOS |
| 123 | - Linux |
| 124 | |
| 125 | ## Boundaries |
| 126 | |
| 127 | - intended to stay independently versioned and releasable |
| 128 | - focused on reusable watch primitives, not a full dev-loop tool |
| 129 | - polling will be the first dependable backend; native backends can come later without changing the high-level surface |
| 130 | - the current polling backend reports event batches and suppresses directory-only metadata churn, so nested file activity is the signal that rises to the top |
| 131 | - current shaping controls include `debounce_polls`, `ignore_hidden`, ignored path prefixes, and `emit_directory_events` |
| 132 | - snapshot read failures preserve the previous watch state, emit no events for that poll, and surface detail through `watch_session%last_error_code` and `watch_session%last_error_message` |
| 133 | - hidden and ignored prefixes are pruned during snapshot collection, so excluded subtrees do not need to be fully scanned first |
| 134 | |
| 135 | ## License |
| 136 | |
| 137 | MIT |