tangled
alpha
login
or
join now
nasso.dev
/
diffwatch
0
fork
atom
Watches a file and prints human-readable, coloured diffs.
0
fork
atom
overview
issues
pulls
pipelines
Initial commit
nasso.dev
3 months ago
4763cf78
+642
5 changed files
expand all
collapse all
unified
split
.gitignore
Cargo.lock
Cargo.toml
README.md
src
main.rs
+1
.gitignore
···
1
1
+
/target
+501
Cargo.lock
···
1
1
+
# This file is automatically @generated by Cargo.
2
2
+
# It is not intended for manual editing.
3
3
+
version = 4
4
4
+
5
5
+
[[package]]
6
6
+
name = "anstream"
7
7
+
version = "0.6.21"
8
8
+
source = "registry+https://github.com/rust-lang/crates.io-index"
9
9
+
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
10
10
+
dependencies = [
11
11
+
"anstyle",
12
12
+
"anstyle-parse",
13
13
+
"anstyle-query",
14
14
+
"anstyle-wincon",
15
15
+
"colorchoice",
16
16
+
"is_terminal_polyfill",
17
17
+
"utf8parse",
18
18
+
]
19
19
+
20
20
+
[[package]]
21
21
+
name = "anstyle"
22
22
+
version = "1.0.13"
23
23
+
source = "registry+https://github.com/rust-lang/crates.io-index"
24
24
+
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
25
25
+
26
26
+
[[package]]
27
27
+
name = "anstyle-parse"
28
28
+
version = "0.2.7"
29
29
+
source = "registry+https://github.com/rust-lang/crates.io-index"
30
30
+
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
31
31
+
dependencies = [
32
32
+
"utf8parse",
33
33
+
]
34
34
+
35
35
+
[[package]]
36
36
+
name = "anstyle-query"
37
37
+
version = "1.1.4"
38
38
+
source = "registry+https://github.com/rust-lang/crates.io-index"
39
39
+
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
40
40
+
dependencies = [
41
41
+
"windows-sys 0.60.2",
42
42
+
]
43
43
+
44
44
+
[[package]]
45
45
+
name = "anstyle-wincon"
46
46
+
version = "3.0.10"
47
47
+
source = "registry+https://github.com/rust-lang/crates.io-index"
48
48
+
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
49
49
+
dependencies = [
50
50
+
"anstyle",
51
51
+
"once_cell_polyfill",
52
52
+
"windows-sys 0.60.2",
53
53
+
]
54
54
+
55
55
+
[[package]]
56
56
+
name = "anyhow"
57
57
+
version = "1.0.100"
58
58
+
source = "registry+https://github.com/rust-lang/crates.io-index"
59
59
+
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
60
60
+
61
61
+
[[package]]
62
62
+
name = "bitflags"
63
63
+
version = "1.3.2"
64
64
+
source = "registry+https://github.com/rust-lang/crates.io-index"
65
65
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
66
66
+
67
67
+
[[package]]
68
68
+
name = "bitflags"
69
69
+
version = "2.9.4"
70
70
+
source = "registry+https://github.com/rust-lang/crates.io-index"
71
71
+
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
72
72
+
73
73
+
[[package]]
74
74
+
name = "clap"
75
75
+
version = "4.5.49"
76
76
+
source = "registry+https://github.com/rust-lang/crates.io-index"
77
77
+
checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f"
78
78
+
dependencies = [
79
79
+
"clap_builder",
80
80
+
"clap_derive",
81
81
+
]
82
82
+
83
83
+
[[package]]
84
84
+
name = "clap_builder"
85
85
+
version = "4.5.49"
86
86
+
source = "registry+https://github.com/rust-lang/crates.io-index"
87
87
+
checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730"
88
88
+
dependencies = [
89
89
+
"anstream",
90
90
+
"anstyle",
91
91
+
"clap_lex",
92
92
+
"strsim",
93
93
+
]
94
94
+
95
95
+
[[package]]
96
96
+
name = "clap_derive"
97
97
+
version = "4.5.49"
98
98
+
source = "registry+https://github.com/rust-lang/crates.io-index"
99
99
+
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
100
100
+
dependencies = [
101
101
+
"heck",
102
102
+
"proc-macro2",
103
103
+
"quote",
104
104
+
"syn",
105
105
+
]
106
106
+
107
107
+
[[package]]
108
108
+
name = "clap_lex"
109
109
+
version = "0.7.6"
110
110
+
source = "registry+https://github.com/rust-lang/crates.io-index"
111
111
+
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
112
112
+
113
113
+
[[package]]
114
114
+
name = "colorchoice"
115
115
+
version = "1.0.4"
116
116
+
source = "registry+https://github.com/rust-lang/crates.io-index"
117
117
+
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
118
118
+
119
119
+
[[package]]
120
120
+
name = "diff"
121
121
+
version = "0.1.13"
122
122
+
source = "registry+https://github.com/rust-lang/crates.io-index"
123
123
+
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
124
124
+
125
125
+
[[package]]
126
126
+
name = "diffwatch"
127
127
+
version = "0.1.0"
128
128
+
dependencies = [
129
129
+
"anyhow",
130
130
+
"clap",
131
131
+
"diff",
132
132
+
"notify",
133
133
+
"termcolor",
134
134
+
]
135
135
+
136
136
+
[[package]]
137
137
+
name = "fsevent-sys"
138
138
+
version = "4.1.0"
139
139
+
source = "registry+https://github.com/rust-lang/crates.io-index"
140
140
+
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
141
141
+
dependencies = [
142
142
+
"libc",
143
143
+
]
144
144
+
145
145
+
[[package]]
146
146
+
name = "heck"
147
147
+
version = "0.5.0"
148
148
+
source = "registry+https://github.com/rust-lang/crates.io-index"
149
149
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
150
150
+
151
151
+
[[package]]
152
152
+
name = "inotify"
153
153
+
version = "0.11.0"
154
154
+
source = "registry+https://github.com/rust-lang/crates.io-index"
155
155
+
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
156
156
+
dependencies = [
157
157
+
"bitflags 2.9.4",
158
158
+
"inotify-sys",
159
159
+
"libc",
160
160
+
]
161
161
+
162
162
+
[[package]]
163
163
+
name = "inotify-sys"
164
164
+
version = "0.1.5"
165
165
+
source = "registry+https://github.com/rust-lang/crates.io-index"
166
166
+
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
167
167
+
dependencies = [
168
168
+
"libc",
169
169
+
]
170
170
+
171
171
+
[[package]]
172
172
+
name = "is_terminal_polyfill"
173
173
+
version = "1.70.1"
174
174
+
source = "registry+https://github.com/rust-lang/crates.io-index"
175
175
+
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
176
176
+
177
177
+
[[package]]
178
178
+
name = "kqueue"
179
179
+
version = "1.1.1"
180
180
+
source = "registry+https://github.com/rust-lang/crates.io-index"
181
181
+
checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a"
182
182
+
dependencies = [
183
183
+
"kqueue-sys",
184
184
+
"libc",
185
185
+
]
186
186
+
187
187
+
[[package]]
188
188
+
name = "kqueue-sys"
189
189
+
version = "1.0.4"
190
190
+
source = "registry+https://github.com/rust-lang/crates.io-index"
191
191
+
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
192
192
+
dependencies = [
193
193
+
"bitflags 1.3.2",
194
194
+
"libc",
195
195
+
]
196
196
+
197
197
+
[[package]]
198
198
+
name = "libc"
199
199
+
version = "0.2.177"
200
200
+
source = "registry+https://github.com/rust-lang/crates.io-index"
201
201
+
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
202
202
+
203
203
+
[[package]]
204
204
+
name = "log"
205
205
+
version = "0.4.28"
206
206
+
source = "registry+https://github.com/rust-lang/crates.io-index"
207
207
+
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
208
208
+
209
209
+
[[package]]
210
210
+
name = "mio"
211
211
+
version = "1.0.4"
212
212
+
source = "registry+https://github.com/rust-lang/crates.io-index"
213
213
+
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
214
214
+
dependencies = [
215
215
+
"libc",
216
216
+
"log",
217
217
+
"wasi",
218
218
+
"windows-sys 0.59.0",
219
219
+
]
220
220
+
221
221
+
[[package]]
222
222
+
name = "notify"
223
223
+
version = "8.2.0"
224
224
+
source = "registry+https://github.com/rust-lang/crates.io-index"
225
225
+
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
226
226
+
dependencies = [
227
227
+
"bitflags 2.9.4",
228
228
+
"fsevent-sys",
229
229
+
"inotify",
230
230
+
"kqueue",
231
231
+
"libc",
232
232
+
"log",
233
233
+
"mio",
234
234
+
"notify-types",
235
235
+
"walkdir",
236
236
+
"windows-sys 0.60.2",
237
237
+
]
238
238
+
239
239
+
[[package]]
240
240
+
name = "notify-types"
241
241
+
version = "2.0.0"
242
242
+
source = "registry+https://github.com/rust-lang/crates.io-index"
243
243
+
checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d"
244
244
+
245
245
+
[[package]]
246
246
+
name = "once_cell_polyfill"
247
247
+
version = "1.70.1"
248
248
+
source = "registry+https://github.com/rust-lang/crates.io-index"
249
249
+
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
250
250
+
251
251
+
[[package]]
252
252
+
name = "proc-macro2"
253
253
+
version = "1.0.101"
254
254
+
source = "registry+https://github.com/rust-lang/crates.io-index"
255
255
+
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
256
256
+
dependencies = [
257
257
+
"unicode-ident",
258
258
+
]
259
259
+
260
260
+
[[package]]
261
261
+
name = "quote"
262
262
+
version = "1.0.41"
263
263
+
source = "registry+https://github.com/rust-lang/crates.io-index"
264
264
+
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
265
265
+
dependencies = [
266
266
+
"proc-macro2",
267
267
+
]
268
268
+
269
269
+
[[package]]
270
270
+
name = "same-file"
271
271
+
version = "1.0.6"
272
272
+
source = "registry+https://github.com/rust-lang/crates.io-index"
273
273
+
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
274
274
+
dependencies = [
275
275
+
"winapi-util",
276
276
+
]
277
277
+
278
278
+
[[package]]
279
279
+
name = "strsim"
280
280
+
version = "0.11.1"
281
281
+
source = "registry+https://github.com/rust-lang/crates.io-index"
282
282
+
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
283
283
+
284
284
+
[[package]]
285
285
+
name = "syn"
286
286
+
version = "2.0.106"
287
287
+
source = "registry+https://github.com/rust-lang/crates.io-index"
288
288
+
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
289
289
+
dependencies = [
290
290
+
"proc-macro2",
291
291
+
"quote",
292
292
+
"unicode-ident",
293
293
+
]
294
294
+
295
295
+
[[package]]
296
296
+
name = "termcolor"
297
297
+
version = "1.4.1"
298
298
+
source = "registry+https://github.com/rust-lang/crates.io-index"
299
299
+
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
300
300
+
dependencies = [
301
301
+
"winapi-util",
302
302
+
]
303
303
+
304
304
+
[[package]]
305
305
+
name = "unicode-ident"
306
306
+
version = "1.0.19"
307
307
+
source = "registry+https://github.com/rust-lang/crates.io-index"
308
308
+
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
309
309
+
310
310
+
[[package]]
311
311
+
name = "utf8parse"
312
312
+
version = "0.2.2"
313
313
+
source = "registry+https://github.com/rust-lang/crates.io-index"
314
314
+
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
315
315
+
316
316
+
[[package]]
317
317
+
name = "walkdir"
318
318
+
version = "2.5.0"
319
319
+
source = "registry+https://github.com/rust-lang/crates.io-index"
320
320
+
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
321
321
+
dependencies = [
322
322
+
"same-file",
323
323
+
"winapi-util",
324
324
+
]
325
325
+
326
326
+
[[package]]
327
327
+
name = "wasi"
328
328
+
version = "0.11.1+wasi-snapshot-preview1"
329
329
+
source = "registry+https://github.com/rust-lang/crates.io-index"
330
330
+
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
331
331
+
332
332
+
[[package]]
333
333
+
name = "winapi-util"
334
334
+
version = "0.1.11"
335
335
+
source = "registry+https://github.com/rust-lang/crates.io-index"
336
336
+
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
337
337
+
dependencies = [
338
338
+
"windows-sys 0.61.2",
339
339
+
]
340
340
+
341
341
+
[[package]]
342
342
+
name = "windows-link"
343
343
+
version = "0.2.1"
344
344
+
source = "registry+https://github.com/rust-lang/crates.io-index"
345
345
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
346
346
+
347
347
+
[[package]]
348
348
+
name = "windows-sys"
349
349
+
version = "0.59.0"
350
350
+
source = "registry+https://github.com/rust-lang/crates.io-index"
351
351
+
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
352
352
+
dependencies = [
353
353
+
"windows-targets 0.52.6",
354
354
+
]
355
355
+
356
356
+
[[package]]
357
357
+
name = "windows-sys"
358
358
+
version = "0.60.2"
359
359
+
source = "registry+https://github.com/rust-lang/crates.io-index"
360
360
+
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
361
361
+
dependencies = [
362
362
+
"windows-targets 0.53.5",
363
363
+
]
364
364
+
365
365
+
[[package]]
366
366
+
name = "windows-sys"
367
367
+
version = "0.61.2"
368
368
+
source = "registry+https://github.com/rust-lang/crates.io-index"
369
369
+
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
370
370
+
dependencies = [
371
371
+
"windows-link",
372
372
+
]
373
373
+
374
374
+
[[package]]
375
375
+
name = "windows-targets"
376
376
+
version = "0.52.6"
377
377
+
source = "registry+https://github.com/rust-lang/crates.io-index"
378
378
+
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
379
379
+
dependencies = [
380
380
+
"windows_aarch64_gnullvm 0.52.6",
381
381
+
"windows_aarch64_msvc 0.52.6",
382
382
+
"windows_i686_gnu 0.52.6",
383
383
+
"windows_i686_gnullvm 0.52.6",
384
384
+
"windows_i686_msvc 0.52.6",
385
385
+
"windows_x86_64_gnu 0.52.6",
386
386
+
"windows_x86_64_gnullvm 0.52.6",
387
387
+
"windows_x86_64_msvc 0.52.6",
388
388
+
]
389
389
+
390
390
+
[[package]]
391
391
+
name = "windows-targets"
392
392
+
version = "0.53.5"
393
393
+
source = "registry+https://github.com/rust-lang/crates.io-index"
394
394
+
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
395
395
+
dependencies = [
396
396
+
"windows-link",
397
397
+
"windows_aarch64_gnullvm 0.53.1",
398
398
+
"windows_aarch64_msvc 0.53.1",
399
399
+
"windows_i686_gnu 0.53.1",
400
400
+
"windows_i686_gnullvm 0.53.1",
401
401
+
"windows_i686_msvc 0.53.1",
402
402
+
"windows_x86_64_gnu 0.53.1",
403
403
+
"windows_x86_64_gnullvm 0.53.1",
404
404
+
"windows_x86_64_msvc 0.53.1",
405
405
+
]
406
406
+
407
407
+
[[package]]
408
408
+
name = "windows_aarch64_gnullvm"
409
409
+
version = "0.52.6"
410
410
+
source = "registry+https://github.com/rust-lang/crates.io-index"
411
411
+
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
412
412
+
413
413
+
[[package]]
414
414
+
name = "windows_aarch64_gnullvm"
415
415
+
version = "0.53.1"
416
416
+
source = "registry+https://github.com/rust-lang/crates.io-index"
417
417
+
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
418
418
+
419
419
+
[[package]]
420
420
+
name = "windows_aarch64_msvc"
421
421
+
version = "0.52.6"
422
422
+
source = "registry+https://github.com/rust-lang/crates.io-index"
423
423
+
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
424
424
+
425
425
+
[[package]]
426
426
+
name = "windows_aarch64_msvc"
427
427
+
version = "0.53.1"
428
428
+
source = "registry+https://github.com/rust-lang/crates.io-index"
429
429
+
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
430
430
+
431
431
+
[[package]]
432
432
+
name = "windows_i686_gnu"
433
433
+
version = "0.52.6"
434
434
+
source = "registry+https://github.com/rust-lang/crates.io-index"
435
435
+
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
436
436
+
437
437
+
[[package]]
438
438
+
name = "windows_i686_gnu"
439
439
+
version = "0.53.1"
440
440
+
source = "registry+https://github.com/rust-lang/crates.io-index"
441
441
+
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
442
442
+
443
443
+
[[package]]
444
444
+
name = "windows_i686_gnullvm"
445
445
+
version = "0.52.6"
446
446
+
source = "registry+https://github.com/rust-lang/crates.io-index"
447
447
+
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
448
448
+
449
449
+
[[package]]
450
450
+
name = "windows_i686_gnullvm"
451
451
+
version = "0.53.1"
452
452
+
source = "registry+https://github.com/rust-lang/crates.io-index"
453
453
+
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
454
454
+
455
455
+
[[package]]
456
456
+
name = "windows_i686_msvc"
457
457
+
version = "0.52.6"
458
458
+
source = "registry+https://github.com/rust-lang/crates.io-index"
459
459
+
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
460
460
+
461
461
+
[[package]]
462
462
+
name = "windows_i686_msvc"
463
463
+
version = "0.53.1"
464
464
+
source = "registry+https://github.com/rust-lang/crates.io-index"
465
465
+
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
466
466
+
467
467
+
[[package]]
468
468
+
name = "windows_x86_64_gnu"
469
469
+
version = "0.52.6"
470
470
+
source = "registry+https://github.com/rust-lang/crates.io-index"
471
471
+
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
472
472
+
473
473
+
[[package]]
474
474
+
name = "windows_x86_64_gnu"
475
475
+
version = "0.53.1"
476
476
+
source = "registry+https://github.com/rust-lang/crates.io-index"
477
477
+
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
478
478
+
479
479
+
[[package]]
480
480
+
name = "windows_x86_64_gnullvm"
481
481
+
version = "0.52.6"
482
482
+
source = "registry+https://github.com/rust-lang/crates.io-index"
483
483
+
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
484
484
+
485
485
+
[[package]]
486
486
+
name = "windows_x86_64_gnullvm"
487
487
+
version = "0.53.1"
488
488
+
source = "registry+https://github.com/rust-lang/crates.io-index"
489
489
+
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
490
490
+
491
491
+
[[package]]
492
492
+
name = "windows_x86_64_msvc"
493
493
+
version = "0.52.6"
494
494
+
source = "registry+https://github.com/rust-lang/crates.io-index"
495
495
+
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
496
496
+
497
497
+
[[package]]
498
498
+
name = "windows_x86_64_msvc"
499
499
+
version = "0.53.1"
500
500
+
source = "registry+https://github.com/rust-lang/crates.io-index"
501
501
+
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
+11
Cargo.toml
···
1
1
+
[package]
2
2
+
name = "diffwatch"
3
3
+
version = "0.1.0"
4
4
+
edition = "2024"
5
5
+
6
6
+
[dependencies]
7
7
+
anyhow = "1.0.100"
8
8
+
clap = { version = "4.5.49", features = ["derive"] }
9
9
+
diff = "0.1.13"
10
10
+
notify = "8.2.0"
11
11
+
termcolor = "1.4.1"
+3
README.md
···
1
1
+
# `diffwatch`
2
2
+
3
3
+
Watches a file and prints human-readable, coloured diffs.
+126
src/main.rs
···
1
1
+
use std::{fs::read_to_string, io::Write as _, path::PathBuf, sync::mpsc};
2
2
+
3
3
+
use clap::{Parser, ValueEnum};
4
4
+
use notify::{RecursiveMode, Watcher};
5
5
+
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
6
6
+
7
7
+
/// Watch a file and print diffs of changes.
8
8
+
#[derive(Debug, Parser)]
9
9
+
#[command(version, about, long_about = None)]
10
10
+
pub struct Args {
11
11
+
/// Path to the file to watch.
12
12
+
file: PathBuf,
13
13
+
14
14
+
/// Whether to enable color output.
15
15
+
#[arg(long, value_enum, default_value_t = ColorMode::Auto)]
16
16
+
color: ColorMode,
17
17
+
18
18
+
/// Show unchanged lines.
19
19
+
#[arg(long, default_value_t = false)]
20
20
+
show_unchanged: bool,
21
21
+
}
22
22
+
23
23
+
#[derive(Debug, Copy, Clone, PartialEq, Eq, ValueEnum)]
24
24
+
enum ColorMode {
25
25
+
Auto,
26
26
+
Always,
27
27
+
Never,
28
28
+
}
29
29
+
30
30
+
impl From<ColorMode> for ColorChoice {
31
31
+
fn from(value: ColorMode) -> Self {
32
32
+
match value {
33
33
+
ColorMode::Auto => Self::Auto,
34
34
+
ColorMode::Always => Self::Always,
35
35
+
ColorMode::Never => Self::Never,
36
36
+
}
37
37
+
}
38
38
+
}
39
39
+
40
40
+
fn main() -> anyhow::Result<()> {
41
41
+
let args = Args::parse();
42
42
+
let (tx, rx) = mpsc::channel();
43
43
+
let mut stdout = StandardStream::stdout(args.color.into());
44
44
+
45
45
+
let mut watcher = notify::recommended_watcher(tx)?;
46
46
+
watcher.watch(&args.file, RecursiveMode::NonRecursive)?;
47
47
+
48
48
+
let mut old_content = read_to_string(&args.file)?;
49
49
+
50
50
+
for evt in rx {
51
51
+
let evt = evt?;
52
52
+
53
53
+
match evt.kind {
54
54
+
notify::EventKind::Create(_) | notify::EventKind::Modify(_) => {
55
55
+
let new_content = read_to_string(&args.file)?;
56
56
+
57
57
+
if old_content == new_content {
58
58
+
// ignore
59
59
+
continue;
60
60
+
}
61
61
+
62
62
+
on_update(&mut stdout, &old_content, &new_content, args.show_unchanged)?;
63
63
+
old_content = new_content;
64
64
+
}
65
65
+
notify::EventKind::Remove(_) => {
66
66
+
stdout.reset()?;
67
67
+
writeln!(&mut stdout, "................ file deleted!")?;
68
68
+
break;
69
69
+
}
70
70
+
_ => {}
71
71
+
}
72
72
+
}
73
73
+
74
74
+
stdout.reset()?;
75
75
+
76
76
+
Ok(())
77
77
+
}
78
78
+
79
79
+
fn on_update(
80
80
+
out: &mut impl WriteColor,
81
81
+
old_content: &str,
82
82
+
new_content: &str,
83
83
+
show_unchanged: bool,
84
84
+
) -> std::io::Result<()> {
85
85
+
let color_deleted = {
86
86
+
let mut color = ColorSpec::new();
87
87
+
color.set_fg(Some(Color::Red));
88
88
+
color
89
89
+
};
90
90
+
let color_unchanged = ColorSpec::new();
91
91
+
let color_added = {
92
92
+
let mut color = ColorSpec::new();
93
93
+
color.set_fg(Some(Color::Green));
94
94
+
color
95
95
+
};
96
96
+
let (mut left_line, mut right_line) = (0, 0);
97
97
+
98
98
+
out.reset()?;
99
99
+
writeln!(out, "................ file modified!")?;
100
100
+
for line in diff::lines(old_content, new_content) {
101
101
+
match line {
102
102
+
diff::Result::Left(l) => {
103
103
+
left_line += 1;
104
104
+
105
105
+
out.set_color(&color_deleted)?;
106
106
+
writeln!(out, "{left_line:>5} - {l}")?;
107
107
+
}
108
108
+
diff::Result::Both(l, _) => {
109
109
+
left_line += 1;
110
110
+
right_line += 1;
111
111
+
if show_unchanged {
112
112
+
out.set_color(&color_unchanged)?;
113
113
+
writeln!(out, "{left_line:>5} {right_line:>5} | {l}")?;
114
114
+
}
115
115
+
}
116
116
+
diff::Result::Right(l) => {
117
117
+
right_line += 1;
118
118
+
out.set_color(&color_added)?;
119
119
+
writeln!(out, " {right_line:>5} + {l}")?;
120
120
+
}
121
121
+
}
122
122
+
}
123
123
+
out.reset()?;
124
124
+
125
125
+
Ok(())
126
126
+
}