Load title from config file
This commit is contained in:
parent
f6d01068a3
commit
da1892710f
6 changed files with 10 additions and 10 deletions
|
|
@ -1,3 +0,0 @@
|
|||
export DEJA_VU_CONFIG=`pwd`/config
|
||||
export DEJA_VU_DATA=`pwd`/data
|
||||
export DEJA_VU_LOG_LEVEL=debug
|
||||
|
|
@ -21,7 +21,6 @@ edition = "2021"
|
|||
license = "GPL"
|
||||
version = "0.2.0"
|
||||
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"app_title": "Deja-vu: Clone Tool",
|
||||
"clone_app_path": "C:/Program Files/Some Clone Tool/app.exe",
|
||||
"keybindings": {
|
||||
"ScanDisks": {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
use std::{
|
||||
env,
|
||||
iter::zip,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl Component for Title {
|
|||
fn draw(&mut self, frame: &mut Frame, area: Rect) -> Result<()> {
|
||||
// Title Block
|
||||
let title_text = Span::styled(
|
||||
"WizardKit: Clone Tool",
|
||||
self.config.app_title.as_str(),
|
||||
Style::default().fg(Color::LightCyan),
|
||||
);
|
||||
let title = Paragraph::new(Line::from(title_text).centered())
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ pub struct AppConfig {
|
|||
|
||||
#[derive(Clone, Debug, Default, Deserialize)]
|
||||
pub struct Config {
|
||||
#[serde(default)]
|
||||
pub app_title: String,
|
||||
#[serde(default)]
|
||||
pub clone_app_path: PathBuf,
|
||||
#[serde(default, flatten)]
|
||||
|
|
@ -68,12 +70,13 @@ impl Config {
|
|||
let data_dir = get_data_dir();
|
||||
let config_dir = get_config_dir();
|
||||
let mut builder = config::Config::builder()
|
||||
.set_default("data_dir", data_dir.to_str().unwrap())?
|
||||
.set_default("config_dir", config_dir.to_str().unwrap())?
|
||||
.set_default("app_title", default_config.app_title.as_str())?
|
||||
.set_default(
|
||||
"clone_app_path",
|
||||
String::from("C:\\Program Files\\Some Clone Tool\\app.exe"),
|
||||
)?;
|
||||
)?
|
||||
.set_default("config_dir", config_dir.to_str().unwrap())?
|
||||
.set_default("data_dir", data_dir.to_str().unwrap())?;
|
||||
|
||||
let config_files = [
|
||||
("config.json5", config::FileFormat::Json5),
|
||||
|
|
@ -95,7 +98,6 @@ impl Config {
|
|||
if !found_config {
|
||||
error!("No configuration file found. Application may not behave as expected");
|
||||
}
|
||||
|
||||
let mut cfg: Self = builder.build()?.try_deserialize()?;
|
||||
|
||||
for (mode, default_bindings) in default_config.keybindings.iter() {
|
||||
|
|
@ -140,7 +142,7 @@ pub fn get_config_dir() -> PathBuf {
|
|||
}
|
||||
|
||||
fn project_directory() -> Option<ProjectDirs> {
|
||||
ProjectDirs::from("com", "WizardKit", env!("CARGO_PKG_NAME"))
|
||||
ProjectDirs::from("com", "Deja-vu", env!("CARGO_PKG_NAME"))
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deref, DerefMut)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue