headson 0.5.2__tar.gz → 0.5.4__tar.gz

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.

Potentially problematic release.


This version of headson might be problematic. Click here for more details.

Files changed (55) hide show
  1. {headson-0.5.2 → headson-0.5.4}/Cargo.lock +1 -1
  2. {headson-0.5.2 → headson-0.5.4}/Cargo.toml +1 -1
  3. {headson-0.5.2 → headson-0.5.4}/PKG-INFO +20 -5
  4. {headson-0.5.2 → headson-0.5.4}/README.md +19 -4
  5. headson-0.5.4/docs/assets/logo.png +0 -0
  6. headson-0.5.4/docs/assets/logo.svg +70 -0
  7. headson-0.5.4/docs/assets/tapes/demo.gif +0 -0
  8. {headson-0.5.2 → headson-0.5.4}/pyproject.toml +1 -1
  9. {headson-0.5.2 → headson-0.5.4}/python/Cargo.lock +2 -2
  10. {headson-0.5.2 → headson-0.5.4}/python/Cargo.toml +1 -1
  11. {headson-0.5.2 → headson-0.5.4}/src/main.rs +16 -9
  12. {headson-0.5.2 → headson-0.5.4}/JSONTestSuite/LICENSE +0 -0
  13. {headson-0.5.2 → headson-0.5.4}/JSONTestSuite/README.md +0 -0
  14. {headson-0.5.2 → headson-0.5.4}/LICENSE +0 -0
  15. {headson-0.5.2 → headson-0.5.4}/docs/assets/algorithm.svg +0 -0
  16. {headson-0.5.2 → headson-0.5.4}/python/README.md +0 -0
  17. {headson-0.5.2 → headson-0.5.4}/python/headson/__init__.py +0 -0
  18. {headson-0.5.2 → headson-0.5.4}/python/src/lib.rs +0 -0
  19. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/builder.rs +0 -0
  20. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/mod.rs +0 -0
  21. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/samplers/default.rs +0 -0
  22. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/samplers/head.rs +0 -0
  23. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/samplers/mod.rs +0 -0
  24. {headson-0.5.2 → headson-0.5.4}/src/json_ingest/samplers/tail.rs +0 -0
  25. {headson-0.5.2 → headson-0.5.4}/src/lib.rs +0 -0
  26. {headson-0.5.2 → headson-0.5.4}/src/order/build.rs +0 -0
  27. {headson-0.5.2 → headson-0.5.4}/src/order/mod.rs +0 -0
  28. {headson-0.5.2 → headson-0.5.4}/src/order/scoring.rs +0 -0
  29. {headson-0.5.2 → headson-0.5.4}/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +0 -0
  30. {headson-0.5.2 → headson-0.5.4}/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +0 -0
  31. {headson-0.5.2 → headson-0.5.4}/src/order/types.rs +0 -0
  32. {headson-0.5.2 → headson-0.5.4}/src/serialization/fileset.rs +0 -0
  33. {headson-0.5.2 → headson-0.5.4}/src/serialization/mod.rs +0 -0
  34. {headson-0.5.2 → headson-0.5.4}/src/serialization/snapshots/headson__serialization__tests__arena_render_empty.snap +0 -0
  35. {headson-0.5.2 → headson-0.5.4}/src/serialization/snapshots/headson__serialization__tests__arena_render_single.snap +0 -0
  36. {headson-0.5.2 → headson-0.5.4}/src/serialization/templates/core.rs +0 -0
  37. {headson-0.5.2 → headson-0.5.4}/src/serialization/templates/js.rs +0 -0
  38. {headson-0.5.2 → headson-0.5.4}/src/serialization/templates/json.rs +0 -0
  39. {headson-0.5.2 → headson-0.5.4}/src/serialization/templates/mod.rs +0 -0
  40. {headson-0.5.2 → headson-0.5.4}/src/serialization/templates/pseudo.rs +0 -0
  41. {headson-0.5.2 → headson-0.5.4}/src/serialization/types.rs +0 -0
  42. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__order__tests__order_empty_array_order.snap +0 -0
  43. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__order__tests__order_single_string_array_order.snap +0 -0
  44. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__order__tests__pq_empty_array_queue.snap +0 -0
  45. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__order__tests__pq_single_string_array_queue.snap +0 -0
  46. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__queue__tests__pq_empty_array_queue.snap +0 -0
  47. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__queue__tests__pq_single_string_array_queue.snap +0 -0
  48. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__tree__tests__build_tree_empty.snap +0 -0
  49. {headson-0.5.2 → headson-0.5.4}/src/snapshots/headson__tree__tests__build_tree_single.snap +0 -0
  50. {headson-0.5.2 → headson-0.5.4}/src/utils/graph.rs +0 -0
  51. {headson-0.5.2 → headson-0.5.4}/src/utils/json.rs +0 -0
  52. {headson-0.5.2 → headson-0.5.4}/src/utils/mod.rs +0 -0
  53. {headson-0.5.2 → headson-0.5.4}/src/utils/search.rs +0 -0
  54. {headson-0.5.2 → headson-0.5.4}/src/utils/text.rs +0 -0
  55. {headson-0.5.2 → headson-0.5.4}/src/utils/tree_arena.rs +0 -0
@@ -266,7 +266,7 @@ dependencies = [
266
266
 
267
267
  [[package]]
268
268
  name = "headson"
269
- version = "0.5.2"
269
+ version = "0.5.4"
270
270
  dependencies = [
271
271
  "anyhow",
272
272
  "assert_cmd",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson"
3
- version = "0.5.2"
3
+ version = "0.5.4"
4
4
  edition = "2024"
5
5
  description = "Budget‑constrained JSON preview renderer"
6
6
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: headson
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Classifier: Programming Language :: Python
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Rust
@@ -13,7 +13,13 @@ Keywords: json,preview,summarize,cli,bindings
13
13
  Requires-Python: >=3.10
14
14
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
15
 
16
- # headson
16
+ <h1 align="center">
17
+ <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="600" height="99" />
18
+ </h1>
19
+ <p align="center">
20
+ <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/tapes/demo.gif" alt="Terminal demo" width="1560" height="900" />
21
+ <br/>
22
+ </p>
17
23
 
18
24
  Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
19
25
 
@@ -58,8 +64,9 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
58
64
 
59
65
  Common flags:
60
66
 
61
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
62
- - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files). Mutually exclusive with `--budget`.
67
+ - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
68
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files).
69
+ - When used together with `--budget`, the final total budget is `min(global, per_file * number_of_inputs)`. Files are only truncated if they don't fit into this final global limit, and no single file expands beyond the per‑file budget.
63
70
  - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
64
71
  - `-m, --compact`: no indentation, no spaces, no newlines
65
72
  - `--no-newline`: single line output
@@ -133,6 +140,14 @@ headson -n 120 -f json users.json
133
140
  # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
134
141
  ```
135
142
 
143
+ ## Terminal Demos
144
+
145
+ Regenerate locally:
146
+
147
+ - Place tapes under docs/tapes (e.g., docs/tapes/demo.tape)
148
+ - Run: cargo make tapes
149
+ - Outputs are written to docs/assets/tapes
150
+
136
151
  ## Python Bindings
137
152
 
138
153
  A thin Python extension module is available on PyPI as `headson`.
@@ -167,7 +182,7 @@ print(
167
182
 
168
183
  # Algorithm
169
184
 
170
- ![Algorithm overview](docs/assets/algorithm.svg)
185
+ ![Algorithm overview](https://raw.githubusercontent.com/kantord/headson/main/docs/assets/algorithm.svg)
171
186
 
172
187
  ## Footnotes
173
188
  - <sup><b>[1]</b></sup> <b>Optimized tree representation</b>: An arena‑style tree stored in flat, contiguous buffers. Each node records its kind and value plus index ranges into shared child and key arrays. Arrays are ingested in a single pass and may be deterministically pre‑sampled: the first element is always kept; additional elements are selected via a fixed per‑index inclusion test; for kept elements, original indices are stored and full lengths are counted. This enables accurate omission info and internal gap markers later, while minimizing pointer chasing.
@@ -1,4 +1,10 @@
1
- # headson
1
+ <h1 align="center">
2
+ <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="600" height="99" />
3
+ </h1>
4
+ <p align="center">
5
+ <img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/tapes/demo.gif" alt="Terminal demo" width="1560" height="900" />
6
+ <br/>
7
+ </p>
2
8
 
3
9
  Head/tail for JSON — but structure‑aware. Get a compact preview that shows both the shape and representative values of your data, all within a strict character budget.
4
10
 
@@ -43,8 +49,9 @@ If you’re comfortable with tools like `head` and `tail`, use `headson` when yo
43
49
 
44
50
  Common flags:
45
51
 
46
- - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the total budget equals `<BYTES> * number_of_inputs`.
47
- - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files). Mutually exclusive with `--budget`.
52
+ - `-n, --budget <BYTES>`: per‑file output budget. When multiple input files are provided, the default total budget equals `<BYTES> * number_of_inputs`.
53
+ - `-N, --global-budget <BYTES>`: total output budget across all inputs. Useful when you want a fixed-size preview across many files (may omit entire files).
54
+ - When used together with `--budget`, the final total budget is `min(global, per_file * number_of_inputs)`. Files are only truncated if they don't fit into this final global limit, and no single file expands beyond the per‑file budget.
48
55
  - `-f, --template <json|pseudo|js>`: output style (default: `pseudo`)
49
56
  - `-m, --compact`: no indentation, no spaces, no newlines
50
57
  - `--no-newline`: single line output
@@ -118,6 +125,14 @@ headson -n 120 -f json users.json
118
125
  # {"users":[{"id":1,"name":"Ana","roles":["admin"]}],"meta":{"count":2}}
119
126
  ```
120
127
 
128
+ ## Terminal Demos
129
+
130
+ Regenerate locally:
131
+
132
+ - Place tapes under docs/tapes (e.g., docs/tapes/demo.tape)
133
+ - Run: cargo make tapes
134
+ - Outputs are written to docs/assets/tapes
135
+
121
136
  ## Python Bindings
122
137
 
123
138
  A thin Python extension module is available on PyPI as `headson`.
@@ -152,7 +167,7 @@ print(
152
167
 
153
168
  # Algorithm
154
169
 
155
- ![Algorithm overview](docs/assets/algorithm.svg)
170
+ ![Algorithm overview](https://raw.githubusercontent.com/kantord/headson/main/docs/assets/algorithm.svg)
156
171
 
157
172
  ## Footnotes
158
173
  - <sup><b>[1]</b></sup> <b>Optimized tree representation</b>: An arena‑style tree stored in flat, contiguous buffers. Each node records its kind and value plus index ranges into shared child and key arrays. Arrays are ingested in a single pass and may be deterministically pre‑sampled: the first element is always kept; additional elements are selected via a fixed per‑index inclusion test; for kept elements, original indices are stored and full lengths are counted. This enables accurate omission info and internal gap markers later, while minimizing pointer chasing.
Binary file
@@ -0,0 +1,70 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ width="18.529102mm"
6
+ height="3.043225mm"
7
+ viewBox="0 0 18.529102 3.043225"
8
+ version="1.1"
9
+ id="svg1"
10
+ inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
11
+ sodipodi:docname="logo.svg"
12
+ inkscape:export-filename="logo.png"
13
+ inkscape:export-xdpi="500"
14
+ inkscape:export-ydpi="500"
15
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
16
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ xmlns:svg="http://www.w3.org/2000/svg">
19
+ <sodipodi:namedview
20
+ id="namedview1"
21
+ pagecolor="#ffffff"
22
+ bordercolor="#000000"
23
+ borderopacity="0.25"
24
+ inkscape:showpageshadow="2"
25
+ inkscape:pageopacity="0.0"
26
+ inkscape:pagecheckerboard="0"
27
+ inkscape:deskcolor="#d1d1d1"
28
+ inkscape:document-units="mm"
29
+ inkscape:zoom="27.623569"
30
+ inkscape:cx="27.856647"
31
+ inkscape:cy="5.8645572"
32
+ inkscape:window-width="3840"
33
+ inkscape:window-height="2124"
34
+ inkscape:window-x="1080"
35
+ inkscape:window-y="748"
36
+ inkscape:window-maximized="1"
37
+ inkscape:current-layer="layer1" />
38
+ <defs id="defs1">
39
+ <style type="text/css"><![CDATA[
40
+ .wordmark { fill: #000000; }
41
+ @media (prefers-color-scheme: dark) {
42
+ .wordmark { fill: #ffffff; }
43
+ }
44
+ ]]></style>
45
+ </defs>
46
+ <g
47
+ inkscape:label="Layer 1"
48
+ inkscape:groupmode="layer"
49
+ id="layer1"
50
+ transform="translate(-62.9858,-133.27801)">
51
+ <g
52
+ id="text1"
53
+ class="wordmark"
54
+ style="font-size:3.175px;stroke-width:0.244"
55
+ aria-label="head{…}son">
56
+ <path
57
+ style="font-family:'Roboto Mono';-inkscape-font-specification:'Roboto Mono'"
58
+ d="m 63.272604,134.32601 v -0.95343 H 62.9858 v 2.38125 h 0.286804 v -1.21853 q 0.03101,-0.0496 0.06976,-0.0899 0.04031,-0.0419 0.08682,-0.0729 0.05891,-0.0403 0.128674,-0.062 0.06976,-0.0217 0.147278,-0.0217 0.09457,-0.002 0.167432,0.0264 0.07286,0.0264 0.120923,0.0806 0.04496,0.0496 0.06821,0.12558 0.02326,0.0744 0.02326,0.17363 v 1.05885 h 0.286804 v -1.05575 q 0,-0.16898 -0.04186,-0.29145 -0.04031,-0.12403 -0.116272,-0.20464 -0.07596,-0.0806 -0.184485,-0.11783 -0.10697,-0.0387 -0.238745,-0.0387 -0.100769,0.002 -0.190686,0.0294 -0.08837,0.0279 -0.162781,0.0822 -0.04651,0.0326 -0.08837,0.076 -0.04186,0.0419 -0.07596,0.093 z m 2.359546,1.45883 q 0.244947,0 0.410828,-0.0977 0.167431,-0.0992 0.251147,-0.22635 l -0.175183,-0.13642 q -0.07906,0.10232 -0.198437,0.16433 -0.119373,0.062 -0.272852,0.062 -0.116272,0 -0.21239,-0.0434 -0.09612,-0.0434 -0.164331,-0.11937 -0.06666,-0.0713 -0.10542,-0.16433 -0.03721,-0.093 -0.04806,-0.21549 v -0.0109 h 1.198376 v -0.12868 q 0,-0.17518 -0.04496,-0.32556 -0.04341,-0.15038 -0.133325,-0.262 -0.08992,-0.11007 -0.226343,-0.17208 -0.134876,-0.0636 -0.31626,-0.0636 -0.144177,0 -0.282153,0.0589 -0.136426,0.0589 -0.243396,0.16898 -0.108521,0.11162 -0.173633,0.27285 -0.06511,0.15968 -0.06511,0.36277 v 0.0651 q 0,0.17519 0.05891,0.32401 0.05891,0.14883 0.164331,0.25735 0.10542,0.10852 0.252698,0.16898 0.148828,0.0605 0.325561,0.0605 z m -0.03721,-1.50379 q 0.110071,0 0.189136,0.0403 0.08061,0.0403 0.133325,0.10542 0.05271,0.0651 0.08217,0.15503 0.02945,0.0884 0.02945,0.16588 v 0.0139 h -0.90227 q 0.01705,-0.11627 0.05891,-0.20464 0.04341,-0.0899 0.10542,-0.15192 0.06201,-0.0605 0.139526,-0.0915 0.07752,-0.0326 0.164331,-0.0326 z m 2.303736,1.47278 h 0.299206 v -0.0248 q -0.02791,-0.0698 -0.04341,-0.16279 -0.0155,-0.0946 -0.0155,-0.17828 v -0.7798 q 0,-0.14107 -0.05116,-0.24649 -0.05116,-0.10542 -0.139526,-0.17674 -0.08992,-0.0698 -0.21239,-0.10387 -0.122473,-0.0357 -0.2651,-0.0357 -0.15658,0 -0.280603,0.0434 -0.122473,0.0434 -0.20774,0.11317 -0.08682,0.0713 -0.133325,0.15968 -0.04496,0.0884 -0.04651,0.17983 h 0.288355 q 0,-0.0527 0.02481,-0.10077 0.02635,-0.0496 0.07286,-0.0853 0.04651,-0.0357 0.113172,-0.0574 0.06821,-0.0217 0.153479,-0.0217 0.09147,0 0.164331,0.0233 0.07441,0.0233 0.125574,0.0651 0.05116,0.0434 0.07906,0.10387 0.02791,0.0605 0.02791,0.13642 v 0.13178 h -0.313159 q -0.175184,0 -0.31781,0.0341 -0.141077,0.0341 -0.241846,0.10232 -0.100769,0.0698 -0.15658,0.17364 -0.05426,0.10387 -0.05426,0.24184 0,0.10542 0.04031,0.19689 0.04186,0.0899 0.117822,0.15503 0.07441,0.0667 0.181384,0.10542 0.108521,0.0388 0.241846,0.0388 0.08217,0 0.155029,-0.0171 0.07286,-0.017 0.137976,-0.0465 0.06356,-0.0294 0.116272,-0.0682 0.05426,-0.0388 0.09767,-0.0822 0.0046,0.0527 0.01395,0.10231 0.01085,0.0481 0.02791,0.0806 z m -0.506946,-0.21859 q -0.08372,0 -0.147278,-0.0217 -0.06356,-0.0217 -0.10542,-0.0605 -0.04186,-0.0372 -0.06356,-0.0899 -0.02015,-0.0527 -0.02015,-0.11473 0,-0.0651 0.02326,-0.11627 0.0248,-0.0512 0.07131,-0.0884 0.06511,-0.0527 0.175183,-0.0775 0.111621,-0.0264 0.260449,-0.0264 h 0.266651 v 0.33951 q -0.02481,0.0496 -0.06821,0.0961 -0.04341,0.045 -0.102319,0.0806 -0.06046,0.0357 -0.133326,0.0574 -0.07286,0.0217 -0.156579,0.0217 z m 1.255737,-0.63407 v 0.0325 q 0,0.17984 0.04806,0.33642 0.04806,0.15503 0.134875,0.26975 0.08682,0.11472 0.20929,0.17983 0.124023,0.0651 0.275952,0.0651 0.155029,0 0.271301,-0.0527 0.116272,-0.0527 0.199988,-0.15503 l 0.0124,0.17673 h 0.263549 v -2.38125 h -0.286804 v 0.86971 q -0.08217,-0.0961 -0.195337,-0.14572 -0.111621,-0.0512 -0.261999,-0.0512 -0.153479,0 -0.277503,0.0636 -0.124023,0.0636 -0.21084,0.17673 -0.08837,0.11317 -0.136425,0.2713 -0.04651,0.15658 -0.04651,0.34417 z m 0.286804,0.0325 v -0.0325 q 0,-0.12247 0.02635,-0.23255 0.02636,-0.11162 0.08217,-0.19688 0.05426,-0.0837 0.139526,-0.13333 0.08682,-0.0496 0.207739,-0.0496 0.141077,0 0.235645,0.0667 0.09457,0.0651 0.150378,0.16743 v 0.77824 q -0.05581,0.11008 -0.150378,0.17519 -0.09457,0.0651 -0.238745,0.0651 -0.119373,0 -0.204639,-0.0481 -0.08527,-0.0496 -0.139526,-0.13332 -0.05581,-0.0837 -0.08217,-0.19379 -0.02635,-0.11007 -0.02635,-0.23255 z m 2.919202,1.38752 0.03256,-0.17829 q -0.09612,-0.003 -0.15968,-0.0527 -0.06201,-0.0496 -0.09922,-0.12712 -0.03876,-0.076 -0.05426,-0.17208 -0.0155,-0.0946 -0.0155,-0.19069 v -0.262 q -0.0016,-0.18448 -0.08682,-0.32401 -0.08527,-0.14108 -0.2651,-0.21239 0.179834,-0.0729 0.2651,-0.21239 0.08682,-0.14108 0.08682,-0.32711 v -0.26355 q 0,-0.0946 0.0093,-0.19069 0.0093,-0.0961 0.04341,-0.17363 0.03256,-0.076 0.09767,-0.12557 0.06666,-0.0496 0.178284,-0.0527 l -0.03256,-0.17829 q -0.15658,0.005 -0.266651,0.0682 -0.11007,0.062 -0.178283,0.16123 -0.07286,0.10387 -0.10697,0.23564 -0.03256,0.13022 -0.03256,0.2558 v 0.26355 q 0,0.22479 -0.10697,0.32556 -0.10542,0.0992 -0.324011,0.0992 v 0.22479 q 0.218591,0.002 0.324011,0.10232 0.10697,0.10077 0.10697,0.32401 v 0.262 q 0,0.12402 0.03566,0.2496 0.03566,0.12712 0.10542,0.22944 0.07286,0.10697 0.182935,0.17208 0.11007,0.0651 0.260449,0.0698 z"
59
+ id="path3" />
60
+ <path
61
+ style="font-family:'Roboto Mono';-inkscape-font-specification:'Roboto Mono';fill:#ff0000"
62
+ d="m 72.653427,135.56779 q 0,0.0899 0.05581,0.15348 0.05736,0.062 0.168982,0.062 0.11007,0 0.168982,-0.062 0.05891,-0.062 0.05891,-0.15348 0,-0.093 -0.05891,-0.15657 -0.05736,-0.0651 -0.168982,-0.0651 -0.113172,0 -0.168982,0.0651 -0.05581,0.0651 -0.05581,0.15657 z m 0.599963,0 q 0,0.0899 0.05581,0.15348 0.05736,0.062 0.168982,0.062 0.110071,0 0.168982,-0.062 0.05891,-0.062 0.05891,-0.15348 0,-0.093 -0.05891,-0.15657 -0.05736,-0.0651 -0.168982,-0.0651 -0.113171,0 -0.168982,0.0651 -0.05581,0.0651 -0.05581,0.15657 z m 0.57981,0 q 0,0.0899 0.05581,0.15348 0.05736,0.062 0.168982,0.062 0.11007,0 0.168981,-0.062 0.05891,-0.062 0.05891,-0.15348 0,-0.093 -0.05891,-0.15657 -0.05736,-0.0651 -0.168981,-0.0651 -0.113172,0 -0.168982,0.0651 -0.05581,0.0651 -0.05581,0.15657 z"
63
+ id="path4" />
64
+ <path
65
+ style="font-family:'Roboto Mono';-inkscape-font-specification:'Roboto Mono'"
66
+ d="m 74.648654,136.14295 0.03256,0.17829 q 0.151929,-0.003 0.261999,-0.0698 0.110071,-0.0667 0.182935,-0.17053 0.07131,-0.10387 0.10542,-0.23099 0.03411,-0.12558 0.03411,-0.2496 v -0.262 q 0,-0.10852 0.02481,-0.18758 0.02481,-0.0791 0.07596,-0.13178 0.05271,-0.0543 0.134876,-0.0791 0.08372,-0.0264 0.195337,-0.0279 v -0.22479 q -0.127124,0 -0.218591,-0.0326 -0.08992,-0.0341 -0.141077,-0.10697 -0.03566,-0.0512 -0.05426,-0.12092 -0.01705,-0.0713 -0.01705,-0.16433 v -0.26355 q 0,-0.13023 -0.03566,-0.26355 -0.03411,-0.13333 -0.113172,-0.2403 -0.06976,-0.0946 -0.178283,-0.15348 -0.106971,-0.0589 -0.257349,-0.0636 l -0.03101,0.17829 q 0.111621,0.003 0.176733,0.0527 0.06511,0.0496 0.09922,0.12557 0.03256,0.0775 0.04186,0.17363 0.01085,0.0961 0.01085,0.19069 v 0.26355 q 0,0.12092 0.03566,0.22479 0.03566,0.10232 0.110071,0.17983 0.03876,0.0419 0.08992,0.076 0.05271,0.0341 0.114721,0.0589 -0.06046,0.0248 -0.111621,0.0574 -0.04961,0.0326 -0.08992,0.0729 -0.07596,0.076 -0.113171,0.17984 -0.03566,0.10387 -0.03566,0.22634 v 0.262 q 0,0.0961 -0.01705,0.19069 -0.0155,0.0961 -0.05271,0.17208 -0.03876,0.0775 -0.102319,0.12712 -0.06356,0.0496 -0.15813,0.0527 z m 2.788977,-0.83405 q 0,0.0403 -0.0155,0.076 -0.0155,0.0357 -0.04496,0.0651 -0.04806,0.0481 -0.133325,0.076 -0.08527,0.0264 -0.199988,0.0264 -0.07286,0 -0.147278,-0.0155 -0.07441,-0.0155 -0.134875,-0.0527 -0.06201,-0.0372 -0.10387,-0.0977 -0.04031,-0.0605 -0.04651,-0.14883 h -0.286804 q 0,0.10697 0.04806,0.20619 0.04961,0.0992 0.142627,0.17363 0.09147,0.076 0.224793,0.12248 0.133325,0.045 0.303857,0.045 0.148828,0 0.274402,-0.0357 0.125574,-0.0357 0.215491,-0.10077 0.08992,-0.0651 0.139526,-0.15658 0.05116,-0.0915 0.05116,-0.20309 0,-0.10387 -0.04496,-0.18293 -0.04341,-0.0791 -0.127124,-0.13953 -0.08372,-0.0589 -0.206189,-0.10077 -0.122473,-0.0434 -0.277502,-0.076 -0.117823,-0.0233 -0.195337,-0.0481 -0.07596,-0.0248 -0.120923,-0.0558 -0.04651,-0.031 -0.06511,-0.0698 -0.0186,-0.0388 -0.0186,-0.0884 0,-0.0481 0.02325,-0.093 0.02325,-0.045 0.06976,-0.0791 0.04496,-0.0341 0.113171,-0.0543 0.06976,-0.0202 0.161231,-0.0202 0.08837,0 0.158129,0.0248 0.07131,0.0248 0.120923,0.0651 0.04961,0.0403 0.07752,0.093 0.02791,0.0512 0.02791,0.10542 h 0.286804 q 0,-0.11007 -0.04806,-0.20464 -0.04651,-0.0961 -0.133325,-0.16743 -0.08682,-0.0713 -0.21084,-0.11163 -0.124023,-0.0403 -0.279052,-0.0403 -0.144178,0 -0.265101,0.0387 -0.119372,0.0388 -0.206189,0.10542 -0.08682,0.0667 -0.134875,0.15658 -0.04806,0.0884 -0.04806,0.19069 0,0.10387 0.04651,0.18293 0.04651,0.0775 0.131775,0.13488 0.08371,0.0589 0.201538,0.10077 0.119372,0.0419 0.263549,0.0713 0.117823,0.0233 0.196888,0.0527 0.07906,0.0279 0.127124,0.062 0.04806,0.0341 0.06821,0.076 0.02015,0.0403 0.02015,0.0915 z m 0.710034,-0.40928 v 0.0341 q 0,0.18139 0.05271,0.33642 0.05271,0.15503 0.151929,0.26975 0.09767,0.11472 0.238745,0.17983 0.142627,0.0651 0.320911,0.0651 0.176733,0 0.31781,-0.0651 0.141076,-0.0651 0.240295,-0.17983 0.09767,-0.11472 0.150379,-0.26975 0.05271,-0.15503 0.05271,-0.33642 v -0.0341 q 0,-0.18139 -0.05271,-0.33642 -0.05271,-0.15657 -0.150379,-0.2713 -0.09922,-0.11472 -0.241846,-0.17983 -0.141076,-0.0667 -0.31936,-0.0667 -0.176733,0 -0.31781,0.0667 -0.141077,0.0651 -0.238745,0.17983 -0.09922,0.11473 -0.151929,0.2713 -0.05271,0.15503 -0.05271,0.33642 z m 0.286804,0.0341 v -0.0341 q 0,-0.12247 0.02946,-0.2341 0.02946,-0.11317 0.08992,-0.19843 0.05891,-0.0853 0.147278,-0.13488 0.08837,-0.0512 0.207739,-0.0512 0.119373,0 0.207739,0.0512 0.08992,0.0496 0.150379,0.13488 0.05891,0.0853 0.08837,0.19843 0.03101,0.11163 0.03101,0.2341 v 0.0341 q 0,0.12403 -0.02945,0.2372 -0.02946,0.11162 -0.08837,0.19689 -0.06046,0.0853 -0.150378,0.13487 -0.08837,0.0496 -0.206189,0.0496 -0.119373,0 -0.20929,-0.0496 -0.08992,-0.0496 -0.148828,-0.13487 -0.06046,-0.0853 -0.08992,-0.19689 -0.02946,-0.11317 -0.02946,-0.2372 z m 1.699122,0.82011 h 0.286804 v -1.20303 q 0.02946,-0.0543 0.06821,-0.0992 0.04031,-0.045 0.08682,-0.0791 0.05736,-0.0388 0.125573,-0.0605 0.06821,-0.0233 0.147278,-0.0233 0.09147,0 0.161231,0.0217 0.07131,0.0217 0.120922,0.0698 0.04806,0.0481 0.07286,0.12557 0.02481,0.0775 0.02481,0.18914 v 1.05885 h 0.286804 v -1.06505 q 0,-0.16743 -0.04186,-0.28836 -0.04031,-0.12247 -0.116272,-0.20153 -0.07596,-0.0791 -0.184485,-0.11628 -0.10697,-0.0372 -0.238745,-0.0372 -0.09767,0.002 -0.186035,0.0294 -0.08682,0.0264 -0.16123,0.076 -0.04961,0.0325 -0.09457,0.0775 -0.04341,0.0434 -0.08061,0.0961 l -0.02015,-0.24805 h -0.257349 z"
67
+ id="path5" />
68
+ </g>
69
+ </g>
70
+ </svg>
Binary file
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "headson"
7
- version = "0.5.2"
7
+ version = "0.5.4"
8
8
  description = "Budget‑constrained JSON preview renderer (Python bindings)"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -169,7 +169,7 @@ dependencies = [
169
169
 
170
170
  [[package]]
171
171
  name = "headson"
172
- version = "0.5.2"
172
+ version = "0.5.4"
173
173
  dependencies = [
174
174
  "anyhow",
175
175
  "clap",
@@ -182,7 +182,7 @@ dependencies = [
182
182
 
183
183
  [[package]]
184
184
  name = "headson-python"
185
- version = "0.5.2"
185
+ version = "0.5.4"
186
186
  dependencies = [
187
187
  "anyhow",
188
188
  "headson",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "headson-python"
3
- version = "0.5.2"
3
+ version = "0.5.4"
4
4
  edition = "2021"
5
5
  publish = false
6
6
  readme = "README.md"
@@ -17,7 +17,7 @@ type IgnoreNotices = Vec<String>;
17
17
  about = "Get a small but useful preview of a JSON file"
18
18
  )]
19
19
  struct Cli {
20
- #[arg(short = 'n', long = "budget", conflicts_with = "global_budget")]
20
+ #[arg(short = 'n', long = "budget")]
21
21
  budget: Option<usize>,
22
22
  #[arg(short = 'f', long = "template", value_enum, default_value_t = Template::Pseudo)]
23
23
  template: Template,
@@ -49,8 +49,7 @@ struct Cli {
49
49
  short = 'N',
50
50
  long = "global-budget",
51
51
  value_name = "BYTES",
52
- conflicts_with = "budget",
53
- help = "Total output budget across all inputs; useful to keep multiple files within a fixed overall output size (may omit entire files)."
52
+ help = "Total output budget across all inputs. When combined with --budget, the effective global limit is the smaller of the two."
54
53
  )]
55
54
  global_budget: Option<usize>,
56
55
  #[arg(
@@ -101,11 +100,11 @@ fn main() -> Result<()> {
101
100
  }
102
101
 
103
102
  fn compute_effective_budget(cli: &Cli, input_count: usize) -> usize {
104
- if let Some(g) = cli.global_budget {
105
- g
106
- } else {
107
- let per_file = cli.budget.unwrap_or(500);
108
- per_file.saturating_mul(input_count)
103
+ match (cli.global_budget, cli.budget) {
104
+ (Some(g), Some(n)) => g.min(n.saturating_mul(input_count)),
105
+ (Some(g), None) => g,
106
+ (None, Some(n)) => n.saturating_mul(input_count),
107
+ (None, None) => 500usize.saturating_mul(input_count),
109
108
  }
110
109
  }
111
110
 
@@ -114,7 +113,15 @@ fn compute_priority(
114
113
  effective_budget: usize,
115
114
  input_count: usize,
116
115
  ) -> headson::PriorityConfig {
117
- let per_file_for_priority = (effective_budget / input_count.max(1)).max(1);
116
+ let per_file_for_priority =
117
+ if cli.global_budget.is_some() && cli.budget.is_some() {
118
+ // When both limits are provided, base per-file heuristics on the per-file
119
+ // budget but also respect the effective per-file slice of the final global.
120
+ let eff_per_file = (effective_budget / input_count.max(1)).max(1);
121
+ cli.budget.unwrap().min(eff_per_file).max(1)
122
+ } else {
123
+ (effective_budget / input_count.max(1)).max(1)
124
+ };
118
125
  get_priority_config(per_file_for_priority, cli)
119
126
  }
120
127
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes