srhickma / padd

Fast and Automatic Formatting of Context-Free Languages
Apache License 2.0
2 stars 2 forks source link

Using `.` for current directory causes panic #194

Closed srhickma closed 5 years ago

srhickma commented 5 years ago

When specifying a formatting target we should be able to specify . to mean the present working directory. This should be relatively simple to fix, but might require some special handling.

Here is an example panic produced from the current cli implementation:

$ ./target/release/padd fmt tests/spec/trailing_whitespace -t .
Loading specification tests/spec/trailing_whitespace ...
Successfully loaded specification: sha256: 5a62844ec1052c40b3e2069d97930e08abf816c0dd8cd3ffac4acc4f86c8091b

panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
stack backtrace:
   0: backtrace::capture::Backtrace::new::h436fb053674243f9 (0x5572c10fc462)
   1: padd::main::{{closure}}::h0bed703fc783b23c (0x5572c10276d5)
   2: std::panicking::rust_panic_with_hook::h057ff03eb4c8000f (0x5572c1178504)
             at src/libstd/panicking.rs:478
   3: std::panicking::continue_panic_fmt::ha6d6ae144369025b (0x5572c117827e)
             at src/libstd/panicking.rs:381
   4: rust_begin_unwind (0x5572c118f525)
             at src/libstd/panicking.rs:308
   5: core::panicking::panic_fmt::hc4f83bfed80aeabd (0x5572c11943cb)
             at src/libcore/panicking.rs:85
   6: core::panicking::panic::h62fdcfa056e70982 (0x5572c119487a)
             at src/libcore/panicking.rs:49
   7: padd::cli::formatter::format_target::h282f8fc95b28bf40 (0x5572c1017669)
   8: padd::cli::formatter::format::h2d3639abb3a85ae7 (0x5572c101498a)
   9: padd::cli::cmd::fmt::hca5427ce0c186984 (0x5572c100fd44)
  10: padd::cli::run::h73ac1768d19b3a5c (0x5572c1022b90)
  11: padd::main::h7bc281c6832dad93 (0x5572c1027394)
  12: std::rt::lang_start::{{closure}}::h99ae8b3de00622d3 (0x5572c0fe5e82)
  13: main (0x5572c1027fdd)
  14: __libc_start_main (0x7f0b2c752b96)
  15: _start (0x5572c0fe1f29)
  16: <unknown> (0x0)
Something terrible has happened, please file an issue at https://github.com/srhickma/padd/issues