yerba 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +492 -15
  3. data/exe/x86_64-linux/yerba +0 -0
  4. data/ext/yerba/extconf.rb +87 -30
  5. data/ext/yerba/include/yerba.h +168 -0
  6. data/ext/yerba/yerba.c +752 -0
  7. data/lib/yerba/collection.rb +31 -0
  8. data/lib/yerba/document.rb +59 -0
  9. data/lib/yerba/formatting.rb +18 -0
  10. data/lib/yerba/location.rb +5 -0
  11. data/lib/yerba/map.rb +166 -0
  12. data/lib/yerba/scalar.rb +85 -0
  13. data/lib/yerba/sequence.rb +182 -0
  14. data/lib/yerba/version.rb +1 -1
  15. data/lib/yerba.rb +32 -4
  16. data/rust/Cargo.lock +378 -2
  17. data/rust/Cargo.toml +5 -1
  18. data/rust/build.rs +11 -0
  19. data/rust/cbindgen.toml +27 -0
  20. data/rust/src/commands/apply.rs +5 -0
  21. data/rust/src/commands/blank_lines.rs +58 -0
  22. data/rust/src/commands/check.rs +5 -0
  23. data/rust/src/commands/delete.rs +35 -0
  24. data/rust/src/commands/get.rs +194 -0
  25. data/rust/src/commands/init.rs +89 -0
  26. data/rust/src/commands/insert.rs +106 -0
  27. data/rust/src/commands/mate.rs +55 -0
  28. data/rust/src/commands/mod.rs +349 -0
  29. data/rust/src/commands/move_item.rs +54 -0
  30. data/rust/src/commands/move_key.rs +87 -0
  31. data/rust/src/commands/quote_style.rs +62 -0
  32. data/rust/src/commands/remove.rs +35 -0
  33. data/rust/src/commands/rename.rs +37 -0
  34. data/rust/src/commands/set.rs +59 -0
  35. data/rust/src/commands/sort.rs +52 -0
  36. data/rust/src/commands/sort_keys.rs +62 -0
  37. data/rust/src/commands/version.rs +8 -0
  38. data/rust/src/document.rs +764 -333
  39. data/rust/src/error.rs +0 -5
  40. data/rust/src/ffi.rs +991 -0
  41. data/rust/src/json.rs +49 -90
  42. data/rust/src/lib.rs +9 -2
  43. data/rust/src/main.rs +55 -843
  44. data/rust/src/selector.rs +241 -0
  45. data/rust/src/syntax.rs +97 -21
  46. data/rust/src/yaml_writer.rs +89 -0
  47. data/rust/src/yerbafile.rs +11 -126
  48. data/yerba.gemspec +5 -0
  49. metadata +34 -1
data/rust/Cargo.lock CHANGED
@@ -52,6 +52,43 @@ dependencies = [
52
52
  "windows-sys",
53
53
  ]
54
54
 
55
+ [[package]]
56
+ name = "anyhow"
57
+ version = "1.0.102"
58
+ source = "registry+https://github.com/rust-lang/crates.io-index"
59
+ checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
60
+
61
+ [[package]]
62
+ name = "bitflags"
63
+ version = "2.11.1"
64
+ source = "registry+https://github.com/rust-lang/crates.io-index"
65
+ checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3"
66
+
67
+ [[package]]
68
+ name = "cbindgen"
69
+ version = "0.28.0"
70
+ source = "registry+https://github.com/rust-lang/crates.io-index"
71
+ checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff"
72
+ dependencies = [
73
+ "clap",
74
+ "heck 0.4.1",
75
+ "indexmap",
76
+ "log",
77
+ "proc-macro2",
78
+ "quote",
79
+ "serde",
80
+ "serde_json",
81
+ "syn",
82
+ "tempfile",
83
+ "toml",
84
+ ]
85
+
86
+ [[package]]
87
+ name = "cfg-if"
88
+ version = "1.0.4"
89
+ source = "registry+https://github.com/rust-lang/crates.io-index"
90
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
91
+
55
92
  [[package]]
56
93
  name = "clap"
57
94
  version = "4.6.1"
@@ -80,7 +117,7 @@ version = "4.6.1"
80
117
  source = "registry+https://github.com/rust-lang/crates.io-index"
81
118
  checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9"
82
119
  dependencies = [
83
- "heck",
120
+ "heck 0.5.0",
84
121
  "proc-macro2",
85
122
  "quote",
86
123
  "syn",
@@ -141,6 +178,41 @@ version = "1.0.2"
141
178
  source = "registry+https://github.com/rust-lang/crates.io-index"
142
179
  checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
143
180
 
181
+ [[package]]
182
+ name = "errno"
183
+ version = "0.3.14"
184
+ source = "registry+https://github.com/rust-lang/crates.io-index"
185
+ checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
186
+ dependencies = [
187
+ "libc",
188
+ "windows-sys",
189
+ ]
190
+
191
+ [[package]]
192
+ name = "fastrand"
193
+ version = "2.4.1"
194
+ source = "registry+https://github.com/rust-lang/crates.io-index"
195
+ checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
196
+
197
+ [[package]]
198
+ name = "foldhash"
199
+ version = "0.1.5"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
202
+
203
+ [[package]]
204
+ name = "getrandom"
205
+ version = "0.4.2"
206
+ source = "registry+https://github.com/rust-lang/crates.io-index"
207
+ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
208
+ dependencies = [
209
+ "cfg-if",
210
+ "libc",
211
+ "r-efi",
212
+ "wasip2",
213
+ "wasip3",
214
+ ]
215
+
144
216
  [[package]]
145
217
  name = "glob"
146
218
  version = "0.3.3"
@@ -153,18 +225,39 @@ version = "0.14.5"
153
225
  source = "registry+https://github.com/rust-lang/crates.io-index"
154
226
  checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
155
227
 
228
+ [[package]]
229
+ name = "hashbrown"
230
+ version = "0.15.5"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
233
+ dependencies = [
234
+ "foldhash",
235
+ ]
236
+
156
237
  [[package]]
157
238
  name = "hashbrown"
158
239
  version = "0.17.0"
159
240
  source = "registry+https://github.com/rust-lang/crates.io-index"
160
241
  checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
161
242
 
243
+ [[package]]
244
+ name = "heck"
245
+ version = "0.4.1"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
248
+
162
249
  [[package]]
163
250
  name = "heck"
164
251
  version = "0.5.0"
165
252
  source = "registry+https://github.com/rust-lang/crates.io-index"
166
253
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
167
254
 
255
+ [[package]]
256
+ name = "id-arena"
257
+ version = "2.3.0"
258
+ source = "registry+https://github.com/rust-lang/crates.io-index"
259
+ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
260
+
168
261
  [[package]]
169
262
  name = "indexmap"
170
263
  version = "2.14.0"
@@ -173,6 +266,8 @@ checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
173
266
  dependencies = [
174
267
  "equivalent",
175
268
  "hashbrown 0.17.0",
269
+ "serde",
270
+ "serde_core",
176
271
  ]
177
272
 
178
273
  [[package]]
@@ -196,18 +291,58 @@ version = "1.0.18"
196
291
  source = "registry+https://github.com/rust-lang/crates.io-index"
197
292
  checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
198
293
 
294
+ [[package]]
295
+ name = "leb128fmt"
296
+ version = "0.1.0"
297
+ source = "registry+https://github.com/rust-lang/crates.io-index"
298
+ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
299
+
300
+ [[package]]
301
+ name = "libc"
302
+ version = "0.2.186"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
305
+
306
+ [[package]]
307
+ name = "linux-raw-sys"
308
+ version = "0.12.1"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
311
+
312
+ [[package]]
313
+ name = "log"
314
+ version = "0.4.29"
315
+ source = "registry+https://github.com/rust-lang/crates.io-index"
316
+ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
317
+
199
318
  [[package]]
200
319
  name = "memchr"
201
320
  version = "2.8.0"
202
321
  source = "registry+https://github.com/rust-lang/crates.io-index"
203
322
  checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
204
323
 
324
+ [[package]]
325
+ name = "once_cell"
326
+ version = "1.21.4"
327
+ source = "registry+https://github.com/rust-lang/crates.io-index"
328
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
329
+
205
330
  [[package]]
206
331
  name = "once_cell_polyfill"
207
332
  version = "1.70.2"
208
333
  source = "registry+https://github.com/rust-lang/crates.io-index"
209
334
  checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
210
335
 
336
+ [[package]]
337
+ name = "prettyplease"
338
+ version = "0.2.37"
339
+ source = "registry+https://github.com/rust-lang/crates.io-index"
340
+ checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
341
+ dependencies = [
342
+ "proc-macro2",
343
+ "syn",
344
+ ]
345
+
211
346
  [[package]]
212
347
  name = "proc-macro2"
213
348
  version = "1.0.106"
@@ -226,6 +361,12 @@ dependencies = [
226
361
  "proc-macro2",
227
362
  ]
228
363
 
364
+ [[package]]
365
+ name = "r-efi"
366
+ version = "6.0.0"
367
+ source = "registry+https://github.com/rust-lang/crates.io-index"
368
+ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
369
+
229
370
  [[package]]
230
371
  name = "rayon"
231
372
  version = "1.12.0"
@@ -264,6 +405,19 @@ version = "1.1.0"
264
405
  source = "registry+https://github.com/rust-lang/crates.io-index"
265
406
  checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
266
407
 
408
+ [[package]]
409
+ name = "rustix"
410
+ version = "1.1.4"
411
+ source = "registry+https://github.com/rust-lang/crates.io-index"
412
+ checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
413
+ dependencies = [
414
+ "bitflags",
415
+ "errno",
416
+ "libc",
417
+ "linux-raw-sys",
418
+ "windows-sys",
419
+ ]
420
+
267
421
  [[package]]
268
422
  name = "rustversion"
269
423
  version = "1.0.22"
@@ -276,6 +430,12 @@ version = "1.0.23"
276
430
  source = "registry+https://github.com/rust-lang/crates.io-index"
277
431
  checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
278
432
 
433
+ [[package]]
434
+ name = "semver"
435
+ version = "1.0.28"
436
+ source = "registry+https://github.com/rust-lang/crates.io-index"
437
+ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
438
+
279
439
  [[package]]
280
440
  name = "serde"
281
441
  version = "1.0.228"
@@ -319,6 +479,15 @@ dependencies = [
319
479
  "zmij",
320
480
  ]
321
481
 
482
+ [[package]]
483
+ name = "serde_spanned"
484
+ version = "0.6.9"
485
+ source = "registry+https://github.com/rust-lang/crates.io-index"
486
+ checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
487
+ dependencies = [
488
+ "serde",
489
+ ]
490
+
322
491
  [[package]]
323
492
  name = "serde_yaml"
324
493
  version = "0.9.34+deprecated"
@@ -349,18 +518,78 @@ dependencies = [
349
518
  "unicode-ident",
350
519
  ]
351
520
 
521
+ [[package]]
522
+ name = "tempfile"
523
+ version = "3.27.0"
524
+ source = "registry+https://github.com/rust-lang/crates.io-index"
525
+ checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
526
+ dependencies = [
527
+ "fastrand",
528
+ "getrandom",
529
+ "once_cell",
530
+ "rustix",
531
+ "windows-sys",
532
+ ]
533
+
352
534
  [[package]]
353
535
  name = "text-size"
354
536
  version = "1.1.1"
355
537
  source = "registry+https://github.com/rust-lang/crates.io-index"
356
538
  checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
357
539
 
540
+ [[package]]
541
+ name = "toml"
542
+ version = "0.8.23"
543
+ source = "registry+https://github.com/rust-lang/crates.io-index"
544
+ checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
545
+ dependencies = [
546
+ "serde",
547
+ "serde_spanned",
548
+ "toml_datetime",
549
+ "toml_edit",
550
+ ]
551
+
552
+ [[package]]
553
+ name = "toml_datetime"
554
+ version = "0.6.11"
555
+ source = "registry+https://github.com/rust-lang/crates.io-index"
556
+ checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
557
+ dependencies = [
558
+ "serde",
559
+ ]
560
+
561
+ [[package]]
562
+ name = "toml_edit"
563
+ version = "0.22.27"
564
+ source = "registry+https://github.com/rust-lang/crates.io-index"
565
+ checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
566
+ dependencies = [
567
+ "indexmap",
568
+ "serde",
569
+ "serde_spanned",
570
+ "toml_datetime",
571
+ "toml_write",
572
+ "winnow",
573
+ ]
574
+
575
+ [[package]]
576
+ name = "toml_write"
577
+ version = "0.1.2"
578
+ source = "registry+https://github.com/rust-lang/crates.io-index"
579
+ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
580
+
358
581
  [[package]]
359
582
  name = "unicode-ident"
360
583
  version = "1.0.24"
361
584
  source = "registry+https://github.com/rust-lang/crates.io-index"
362
585
  checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
363
586
 
587
+ [[package]]
588
+ name = "unicode-xid"
589
+ version = "0.2.6"
590
+ source = "registry+https://github.com/rust-lang/crates.io-index"
591
+ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
592
+
364
593
  [[package]]
365
594
  name = "unsafe-libyaml"
366
595
  version = "0.2.11"
@@ -373,6 +602,58 @@ version = "0.2.2"
373
602
  source = "registry+https://github.com/rust-lang/crates.io-index"
374
603
  checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
375
604
 
605
+ [[package]]
606
+ name = "wasip2"
607
+ version = "1.0.3+wasi-0.2.9"
608
+ source = "registry+https://github.com/rust-lang/crates.io-index"
609
+ checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
610
+ dependencies = [
611
+ "wit-bindgen 0.57.1",
612
+ ]
613
+
614
+ [[package]]
615
+ name = "wasip3"
616
+ version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
617
+ source = "registry+https://github.com/rust-lang/crates.io-index"
618
+ checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
619
+ dependencies = [
620
+ "wit-bindgen 0.51.0",
621
+ ]
622
+
623
+ [[package]]
624
+ name = "wasm-encoder"
625
+ version = "0.244.0"
626
+ source = "registry+https://github.com/rust-lang/crates.io-index"
627
+ checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
628
+ dependencies = [
629
+ "leb128fmt",
630
+ "wasmparser",
631
+ ]
632
+
633
+ [[package]]
634
+ name = "wasm-metadata"
635
+ version = "0.244.0"
636
+ source = "registry+https://github.com/rust-lang/crates.io-index"
637
+ checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
638
+ dependencies = [
639
+ "anyhow",
640
+ "indexmap",
641
+ "wasm-encoder",
642
+ "wasmparser",
643
+ ]
644
+
645
+ [[package]]
646
+ name = "wasmparser"
647
+ version = "0.244.0"
648
+ source = "registry+https://github.com/rust-lang/crates.io-index"
649
+ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
650
+ dependencies = [
651
+ "bitflags",
652
+ "hashbrown 0.15.5",
653
+ "indexmap",
654
+ "semver",
655
+ ]
656
+
376
657
  [[package]]
377
658
  name = "windows-link"
378
659
  version = "0.2.1"
@@ -397,6 +678,100 @@ dependencies = [
397
678
  "memchr",
398
679
  ]
399
680
 
681
+ [[package]]
682
+ name = "wit-bindgen"
683
+ version = "0.51.0"
684
+ source = "registry+https://github.com/rust-lang/crates.io-index"
685
+ checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
686
+ dependencies = [
687
+ "wit-bindgen-rust-macro",
688
+ ]
689
+
690
+ [[package]]
691
+ name = "wit-bindgen"
692
+ version = "0.57.1"
693
+ source = "registry+https://github.com/rust-lang/crates.io-index"
694
+ checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
695
+
696
+ [[package]]
697
+ name = "wit-bindgen-core"
698
+ version = "0.51.0"
699
+ source = "registry+https://github.com/rust-lang/crates.io-index"
700
+ checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
701
+ dependencies = [
702
+ "anyhow",
703
+ "heck 0.5.0",
704
+ "wit-parser",
705
+ ]
706
+
707
+ [[package]]
708
+ name = "wit-bindgen-rust"
709
+ version = "0.51.0"
710
+ source = "registry+https://github.com/rust-lang/crates.io-index"
711
+ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
712
+ dependencies = [
713
+ "anyhow",
714
+ "heck 0.5.0",
715
+ "indexmap",
716
+ "prettyplease",
717
+ "syn",
718
+ "wasm-metadata",
719
+ "wit-bindgen-core",
720
+ "wit-component",
721
+ ]
722
+
723
+ [[package]]
724
+ name = "wit-bindgen-rust-macro"
725
+ version = "0.51.0"
726
+ source = "registry+https://github.com/rust-lang/crates.io-index"
727
+ checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
728
+ dependencies = [
729
+ "anyhow",
730
+ "prettyplease",
731
+ "proc-macro2",
732
+ "quote",
733
+ "syn",
734
+ "wit-bindgen-core",
735
+ "wit-bindgen-rust",
736
+ ]
737
+
738
+ [[package]]
739
+ name = "wit-component"
740
+ version = "0.244.0"
741
+ source = "registry+https://github.com/rust-lang/crates.io-index"
742
+ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
743
+ dependencies = [
744
+ "anyhow",
745
+ "bitflags",
746
+ "indexmap",
747
+ "log",
748
+ "serde",
749
+ "serde_derive",
750
+ "serde_json",
751
+ "wasm-encoder",
752
+ "wasm-metadata",
753
+ "wasmparser",
754
+ "wit-parser",
755
+ ]
756
+
757
+ [[package]]
758
+ name = "wit-parser"
759
+ version = "0.244.0"
760
+ source = "registry+https://github.com/rust-lang/crates.io-index"
761
+ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
762
+ dependencies = [
763
+ "anyhow",
764
+ "id-arena",
765
+ "indexmap",
766
+ "log",
767
+ "semver",
768
+ "serde",
769
+ "serde_derive",
770
+ "serde_json",
771
+ "unicode-xid",
772
+ "wasmparser",
773
+ ]
774
+
400
775
  [[package]]
401
776
  name = "yaml_parser"
402
777
  version = "0.3.0"
@@ -409,8 +784,9 @@ dependencies = [
409
784
 
410
785
  [[package]]
411
786
  name = "yerba"
412
- version = "0.1.2"
787
+ version = "0.2.1"
413
788
  dependencies = [
789
+ "cbindgen",
414
790
  "clap",
415
791
  "glob",
416
792
  "indoc",
data/rust/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "yerba"
3
- version = "0.1.2"
3
+ version = "0.2.1"
4
4
  edition = "2021"
5
5
  authors = ["Marco Roth <marco.roth@intergga.ch>"]
6
6
  description = "YAML Editing and Refactoring with Better Accuracy"
@@ -13,6 +13,7 @@ categories = ["parser-implementations", "development-tools"]
13
13
  [lib]
14
14
  name = "yerba"
15
15
  path = "src/lib.rs"
16
+ crate-type = ["cdylib", "rlib"]
16
17
 
17
18
  [[bin]]
18
19
  name = "yerba"
@@ -29,4 +30,7 @@ clap = { version = "4", features = ["derive"] }
29
30
  indoc = "2"
30
31
  rayon = "1"
31
32
 
33
+ [build-dependencies]
34
+ cbindgen = "0.28"
35
+
32
36
  [dev-dependencies]
data/rust/build.rs ADDED
@@ -0,0 +1,11 @@
1
+ use std::env;
2
+ use std::path::PathBuf;
3
+
4
+ fn main() {
5
+ let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
6
+ let header_path = PathBuf::from(&crate_dir).join("../ext/yerba/include/yerba.h");
7
+
8
+ if let Ok(bindings) = cbindgen::generate(&crate_dir) {
9
+ bindings.write_to_file(&header_path);
10
+ }
11
+ }
@@ -0,0 +1,27 @@
1
+ language = "C"
2
+ header = """/* Generated by cbindgen — do not edit manually */
3
+
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+ #include <stddef.h>"""
7
+ include_guard = "YERBA_H"
8
+ no_includes = true
9
+
10
+ [export]
11
+ include = [
12
+ "YerbaValueType",
13
+ "YerbaResult",
14
+ "YerbaTypedValue",
15
+ "YerbaTypedList",
16
+ "YerbaGetResult",
17
+ ]
18
+
19
+ [enum]
20
+ rename_variants = "ScreamingSnakeCase"
21
+ prefix_with_name = true
22
+
23
+ [fn]
24
+ sort_by = "None"
25
+
26
+ [parse]
27
+ parse_deps = false
@@ -0,0 +1,5 @@
1
+ use super::run_yerbafile;
2
+
3
+ pub fn run() {
4
+ run_yerbafile(true);
5
+ }
@@ -0,0 +1,58 @@
1
+ use std::sync::LazyLock;
2
+
3
+ use indoc::indoc;
4
+
5
+ use super::colorize_examples;
6
+ use super::{output, parse_file, resolve_files};
7
+
8
+ static EXAMPLES: LazyLock<String> = LazyLock::new(|| {
9
+ colorize_examples(indoc! {r#"
10
+ yerba blank-lines videos.yml 1
11
+ yerba blank-lines videos.yml "[]" 1
12
+ yerba blank-lines videos.yml "[].speakers" 1
13
+ yerba blank-lines config.yml "tags" 0
14
+ "#})
15
+ });
16
+
17
+ #[derive(clap::Args)]
18
+ #[command(
19
+ about = "Enforce blank lines between sequence entries",
20
+ arg_required_else_help = true,
21
+ after_help = EXAMPLES.as_str()
22
+ )]
23
+ pub struct Args {
24
+ file: String,
25
+ /// Selector or count (if a number, treated as count for root-level sequence)
26
+ first: String,
27
+ /// Count (when selector is provided as first positional)
28
+ second: Option<usize>,
29
+ #[arg(long)]
30
+ dry_run: bool,
31
+ }
32
+
33
+ impl Args {
34
+ pub fn run(self) {
35
+ let (selector, count) = if let Some(count) = self.second {
36
+ (self.first.as_str(), count)
37
+ } else if let Ok(count) = self.first.parse::<usize>() {
38
+ ("", count)
39
+ } else {
40
+ use super::color::*;
41
+
42
+ eprintln!(
43
+ "{RED}Error:{RESET} expected a number for blank line count, got '{}'",
44
+ self.first
45
+ );
46
+
47
+ std::process::exit(1);
48
+ };
49
+
50
+ for resolved_file in resolve_files(&self.file) {
51
+ let mut document = parse_file(&resolved_file);
52
+
53
+ if document.enforce_blank_lines(selector, count).is_ok() {
54
+ output(&resolved_file, &document, self.dry_run);
55
+ }
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,5 @@
1
+ use super::run_yerbafile;
2
+
3
+ pub fn run() {
4
+ run_yerbafile(false);
5
+ }
@@ -0,0 +1,35 @@
1
+ use std::sync::LazyLock;
2
+
3
+ use indoc::indoc;
4
+
5
+ use super::colorize_examples;
6
+ use super::{output, parse_file, run_op};
7
+
8
+ static EXAMPLES: LazyLock<String> = LazyLock::new(|| {
9
+ colorize_examples(indoc! {r#"
10
+ yerba delete config.yml "database.pool"
11
+ yerba delete videos.yml "[0].description"
12
+ yerba delete config.yml "database.pool" --dry-run
13
+ "#})
14
+ });
15
+
16
+ #[derive(clap::Args)]
17
+ #[command(
18
+ about = "Delete a key and its value from a map",
19
+ arg_required_else_help = true,
20
+ after_help = EXAMPLES.as_str()
21
+ )]
22
+ pub struct Args {
23
+ file: String,
24
+ selector: String,
25
+ #[arg(long)]
26
+ dry_run: bool,
27
+ }
28
+
29
+ impl Args {
30
+ pub fn run(self) {
31
+ let mut document = parse_file(&self.file);
32
+ run_op(|| document.delete(&self.selector));
33
+ output(&self.file, &document, self.dry_run);
34
+ }
35
+ }