replacement in common/beancount-tree-writer/src/lib.rs at line 1
− use beancount_pretty_printer::Config as PrettyPrinterConfig;
+ pub use config::Config;
+
edit in common/beancount-tree-writer/src/lib.rs at line 8
− use color_eyre::eyre::format_err;
− use color_eyre::Help;
− use color_eyre::Report;
− use color_eyre::Result;
replacement in common/beancount-tree-writer/src/lib.rs at line 21
[4.651]→[3.0:17](∅→∅),
[3.17]→[4.651:708](∅→∅),
[4.651]→[4.651:708](∅→∅) − #[derive(Debug)]
− pub struct Config {
− pub base_directory: Utf8PathBuf,
edit in common/beancount-tree-writer/src/lib.rs at line 23
[4.63]→[4.63:108](∅→∅),
[4.108]→[4.708:771](∅→∅),
[4.708]→[4.708:771](∅→∅) − pub pretty_printer: PrettyPrinterConfig,
− }
−
− #[derive(Debug, Snafu)]
− pub struct TreeWriterError(Error);
−
replacement in common/beancount-tree-writer/src/lib.rs at line 24
[4.795]→[4.795:1225](∅→∅) − enum Error {
− #[snafu(display("encountered unsupported directive while indexing: {directive:?}"))]
− IndexingDirective {
− backtrace: Backtrace,
− directive: Directive,
− },
− #[snafu(display("error while pretty printing directives for key {index:?} to {file}"))]
− PrettyPrinting {
− backtrace: Backtrace,
− file: Utf8PathBuf,
− index: DirectiveIndex,
− source: io::Error,
− },
− }
+ pub struct Error(InnerError);
replacement in common/beancount-tree-writer/src/lib.rs at line 27
[4.1250]→[4.1250:1270](∅→∅) + config: config::Config,
replacement in common/beancount-tree-writer/src/lib.rs at line 31
[4.1291]→[4.1291:1332](∅→∅) − pub fn new(config: Config) -> Self {
+ pub fn new(config: config::Config) -> Self {
edit in common/beancount-tree-writer/src/lib.rs at line 38
+ let pretty_printer_config = match self.config.pretty_printer {
+ config::PrettyPrinterConfig::GloballyDerived => Some(
+ beancount_pretty_printer::Config::derive_from_directives(&directives),
+ ),
+ config::PrettyPrinterConfig::LocallyDerived => None,
+ config::PrettyPrinterConfig::Static(config) => Some(config),
+ };
+
replacement in common/beancount-tree-writer/src/lib.rs at line 56
[4.1834]→[4.1834:1910](∅→∅) − .map(|(index, directives)| self.write_month(index, directives))
+ .map(|(index, directives)| self.write_month(pretty_printer_config, index, directives))
replacement in common/beancount-tree-writer/src/lib.rs at line 63
[4.2049]→[4.2049:2225](∅→∅) − Err(errors.into_iter().fold(
− format_err!("encountered errors while writing directives to file tree"),
− Report::error,
− ))
+ todo!("convert errors to summarized report")
edit in common/beancount-tree-writer/src/lib.rs at line 71
+ pretty_printer_config: Option<beancount_pretty_printer::Config>,
replacement in common/beancount-tree-writer/src/lib.rs at line 74
[4.2368]→[4.2368:2397](∅→∅) − ) -> Result<(), Error> {
+ ) -> Result<(), InnerError> {
replacement in common/beancount-tree-writer/src/lib.rs at line 77
[4.2451]→[4.2451:2514](∅→∅) − let file = index.file_in(&self.config.base_directory);
+ let pretty_printer_config = pretty_printer_config.unwrap_or_else(|| {
+ beancount_pretty_printer::Config::derive_from_directives(&directives)
+ });
+
+ let file = index.file_in(&self.config.output_path);
replacement in common/beancount-tree-writer/src/lib.rs at line 84
[4.2575]→[4.109:234](∅→∅) − PrettyPrinter::buffered(self.config.pretty_printer, file)
− .print_directives(&directives)
+ PrettyPrinter::buffered(pretty_printer_config, file).print_directives(&directives)
replacement in common/beancount-tree-writer/src/lib.rs at line 131
[4.3849]→[4.3849:3873](∅→∅) + type Error = InnerError;
edit in common/beancount-tree-writer/src/lib.rs at line 152
+ }
+
+ #[derive(Debug, Snafu)]
+ enum InnerError {
+ #[snafu(display("encountered unsupported directive while indexing: {directive:?}"))]
+ IndexingDirective {
+ backtrace: Backtrace,
+ directive: Directive,
+ },
+ #[snafu(display("error while pretty printing directives for key {index:?} to {file}"))]
+ PrettyPrinting {
+ backtrace: Backtrace,
+ file: Utf8PathBuf,
+ index: DirectiveIndex,
+ source: io::Error,
+ },
edit in common/beancount-tree-writer/src/lib.rs at line 169
+
+ type Result<T, E = Error> = std::result::Result<T, E>;
replacement in common/beancount-tree-writer/Cargo.toml at line 16
[4.4724]→[4.4724:4801](∅→∅) − [dependencies.beancount-pretty-printer]
− path = "../beancount-pretty-printer"
+ # Workspace dependencies
+ beancount-pretty-printer.path = "../beancount-pretty-printer"
+ beancount-types.path = "../beancount-types"
replacement in common/beancount-tree-writer/Cargo.toml at line 20
[4.4802]→[4.4802:4861](∅→∅) − [dependencies.beancount-types]
− path = "../beancount-types"
+ # Inherited from workspace
+ serde.workspace = true
+
edit in common/beancount-pretty-printer/src/lib.rs at line 21
+ use serde::Deserialize;
replacement in common/beancount-pretty-printer/src/lib.rs at line 30
− #[derive(Clone, Copy, Debug)]
+ #[derive(Clone, Copy, Debug, Deserialize)]
replacement in common/beancount-pretty-printer/src/lib.rs at line 73
− #[derive(Clone, Copy, Debug)]
+ #[derive(Clone, Copy, Debug, Deserialize)]
edit in common/beancount-pretty-printer/Cargo.toml at line 23