mistgc / bili-live-chat

A bilibili streaming chat tool using TUI written in Rust.
24 stars 3 forks source link

[BUG] Can't load config file specified by `--config` #2

Closed futuretech6 closed 1 year ago

futuretech6 commented 1 year ago

I try to put the config file outside the default path and use --config to specify it. However, the program fails to parse the config path

$ RUST_BACKTRACE=1 cargo run --release -- --config config.yaml -d 23141761
   Compiling bili-live-chat v0.1.0 (/home/ulysses/Git/bili-live-chat)
    Finished release [optimized] target(s) in 4.43s
     Running `target/release/bili-live-chat --config config.yaml -d 23141761`
thread 'main' panicked at 'Mismatch between definition and access of `config`. Could not downcast to TypeId { t: 15790872368546094999 }, need to downcast to TypeId { t: 1345200085165903335 }
', /home/ulysses/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/clap-4.1.1/src/parser/error.rs:30:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
   2: clap::parser::matches::arg_matches::ArgMatches::get_one
   3: bili_live_chat::cli_init
   4: tokio::runtime::park::CachedParkThread::block_on
   5: tokio::runtime::runtime::Runtime::block_on
   6: bili_live_chat::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I try to comment out the path buf settings in --config parser then the program can start normally.

.arg(
    arg!(
        -c --config <FILE> "Sets loading path for config file"
    )
    .required(false),
    // .value_parser(value_parser!(PathBuf)),
)

This is a temporary solution, there must be some other ways to do the path check, but I am not familiar with Rust programming.

mistgc commented 1 year ago

Thanks for your issue. Maybe I will fix it tonight.

mistgc commented 1 year ago

This issue may be solved at de967ce495c5bf28340b64f28ca70fa4ea4a361d.