refactor uu_df so crate users can call df without printing to stdout.#12281
refactor uu_df so crate users can call df without printing to stdout.#12281philocalyst wants to merge 10 commits into
Conversation
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 19.55%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Memory | cp_recursive_deep_tree[(120, 4)] |
562.5 KB | 699.2 KB | -19.55% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing philocalyst:open-df (fcc342c) with main (6a942ba)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
Believe the tr failure isn't my own. Have an idea for a commit that should fix the perf issues! Awesome tooling y'all have. |
|
I've only added code in df/ so I don't believe the cp issue is mine, either. |
|
It is very hard to distinguish |
|
@oech3 You're encouraging me to move to a wrapper type? |
|
Sorry. I don't understand what you are asking. But... why does nushell need to use internal functions instead of just calling |
|
@oech3 because nushell outputs structured data and not just strings that println!() or eprintln!() outputs. Nushell also needs to be able to pass parameters into the crate with nushell parsing the parameters and the passing those values into the crate. Nushell also creates "nice" error messages from this data if necessary with spans. Calling uu_app wouldn't help with any of this. |
|
I think it is impossible to guarantee stable API at here. |
|
Parsing stdout would be nightmare, but it is the most stable API. |
refactor uu_df so crate users can call df without printing to stdout. This is for tackling this nushell issue.
It opens
uu_dffor crate users that want structured filesystem data instead of parsing the text table printed to stdout. This allows the people over at nushell (probably me, who will write the PR), to incorporate it cleanly. Other people too, I'm sure!The new API follows the same pattern as the recent
uu_lswork (thanks @fdncred !):df_with_outputgathers filesystem data and sends it to a caller-provided output sink.DfOutputsupports both batch and streaming consumers.StreamingOutputcollectsFilesystemvalues for awesome programmatic use.TextOutputpreserves the existing command-line table behavior.dfremains the normal text-output entry point and delegates through the (new!) shared path.Filesystemis now public because it is the structured data crate users need. I kept the existing fields as the public API surface, since they already expose the mount information and usage data without requiring an additional wrapper type. Also plenty of nice documentation is around!Some notes:
StreamingOutputis meant as the easiest starting point for nushell or other crate users.Would love feedback!