Finally I modified clap to accept either a file or a string.
It came with a couple of architectural changes:
➖ I decided to clean the Session struct, because it wasn't really relevant to have it.
➖ Input was also a rock the way to interpret files to format. So also it was deleted for better code readability
➕ I added 2 functions: format_single_file and format_string that redirects the code to format_inner, where the code is formatted. The first 2 functions have the responsibility of reading & writing the file, or writing to stdout respectably.
Finally I modified
clap
to accept either a file or a string.It came with a couple of architectural changes:
Session
struct, because it wasn't really relevant to have it.Input
was also a rock the way to interpret files to format. So also it was deleted for better code readabilityformat_single_file
andformat_string
that redirects the code toformat_inner
, where the code is formatted. The first 2 functions have the responsibility of reading & writing the file, or writing to stdout respectably.