chore: 程序开始时打印欢迎信息,调整日志和构建流 (#285)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "Bili-Sync", version = version(), about, long_about = None)]
|
||||
#[command(name = "Bili-Sync", version = detail_version(), about, long_about = None)]
|
||||
pub struct Args {
|
||||
#[arg(short, long, env = "SCAN_ONLY")]
|
||||
pub scan_only: bool,
|
||||
@@ -14,19 +16,22 @@ mod built_info {
|
||||
include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
||||
}
|
||||
|
||||
fn version() -> String {
|
||||
let version = if let (Some(git_version), Some(git_dirty)) = (built_info::GIT_VERSION, built_info::GIT_DIRTY) {
|
||||
format!("{}{}", git_version, if git_dirty { "-dirty" } else { "" })
|
||||
pub fn version() -> Cow<'static, str> {
|
||||
if let (Some(git_version), Some(git_dirty)) = (built_info::GIT_VERSION, built_info::GIT_DIRTY) {
|
||||
Cow::Owned(format!("{}{}", git_version, if git_dirty { "-dirty" } else { "" }))
|
||||
} else {
|
||||
built_info::PKG_VERSION.to_owned()
|
||||
};
|
||||
Cow::Borrowed(built_info::PKG_VERSION)
|
||||
}
|
||||
}
|
||||
|
||||
fn detail_version() -> String {
|
||||
format!(
|
||||
"{}
|
||||
Architecture: {}-{}
|
||||
Author: {}
|
||||
Built Time: {}
|
||||
Rustc Version: {}",
|
||||
version,
|
||||
version(),
|
||||
built_info::CFG_OS,
|
||||
built_info::CFG_TARGET_ARCH,
|
||||
built_info::PKG_AUTHORS,
|
||||
|
||||
@@ -40,6 +40,7 @@ pub static CONFIG_DIR: Lazy<PathBuf> =
|
||||
|
||||
#[cfg(not(test))]
|
||||
fn load_config() -> Config {
|
||||
info!("开始加载配置文件..");
|
||||
let config = Config::load().unwrap_or_else(|err| {
|
||||
if err
|
||||
.downcast_ref::<std::io::Error>()
|
||||
@@ -47,7 +48,7 @@ fn load_config() -> Config {
|
||||
{
|
||||
panic!("加载配置文件失败,错误为: {err}");
|
||||
}
|
||||
warn!("配置文件不存在,使用默认配置...");
|
||||
warn!("配置文件不存在,使用默认配置..");
|
||||
Config::default()
|
||||
});
|
||||
info!("配置文件加载完毕,覆盖刷新原有配置");
|
||||
|
||||
@@ -14,6 +14,7 @@ mod item;
|
||||
|
||||
use crate::adapter::Args;
|
||||
use crate::bilibili::{CollectionItem, Credential, DanmakuOption, FilterOption};
|
||||
pub use crate::config::clap::version;
|
||||
pub use crate::config::global::{ARGS, CONFIG, CONFIG_DIR, TEMPLATE};
|
||||
use crate::config::item::{ConcurrentLimit, deserialize_collection_list, serialize_collection_list};
|
||||
pub use crate::config::item::{NFOTimeType, PathSafeTemplate, RateLimit, WatchLaterConfig};
|
||||
|
||||
Reference in New Issue
Block a user