toipe icon indicating copy to clipboard operation
toipe copied to clipboard

Save Results

Open PriceHiller opened this issue 3 years ago • 1 comments

This PR closes issue #11.

Summary

This PR adds the ability to save results to a file via the -r flag. In the current implementation results are not saved by default, instead the user must pass either the new -r flag and a path or set the TOIPE_RESULTS_FILE environment variable to a file path.

Notes

The only thing that we might want to modify is the error type being returned by the save_results function I've added. I do not use ToipeError and instead fall back on std::io::Error which gets unrolled up where it is then turned into ToipeError, but in doing so the error information is dropped. See here for the save_results function and here for how I'm taking the error in and returning ToipeError.
Let me know what suggestions you have and I'll be happy to make any relevant modifications. I'm not the biggest Rust guy, so I may have missed more idiomatic patterns that would improve this PR.

PriceHiller avatar Aug 11 '22 02:08 PriceHiller

Thank you for this @treatybreaker. I haven't been able to find time to review this PR thoroughly, it will take some more time.

Some thoughts though:

  • I think the results should be saved by default. With a flag to disable them. Something like -r NONE to disable saving and -r filepath to save to a different file. (This is also how neovim works for its -u flag).
  • As for the error handling part, I was moving toipe to use anyhow in #40. I'll update here once that is merged and you can use that.

Samyak2 avatar Oct 21 '22 18:10 Samyak2