Skip to content

Commit

Permalink
refactor: update config to template
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 30, 2021
1 parent 0ba7bb7 commit f7b7859
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions libs/quake_processor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Processor




4 changes: 4 additions & 0 deletions quake_core/src/entry/entry_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ impl EntryPaths {
}
}

pub fn quake_config() -> &'static str {
".quake.yaml"
}

pub fn entries_define() -> &'static str {
"entries-define.yaml"
}
Expand Down
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use pagedump::page_dump;
use tracing::{debug, error};

use quake_core::entry::entry_defines::EntryDefines;
use quake_core::entry::entry_paths::EntryPaths;
use quake_core::quake::QuakeActionNode;
use quake_core::QuakeConfig;
use quake_tui::tui_main_loop;
Expand Down Expand Up @@ -97,6 +98,7 @@ async fn main() {
let opts: Opts = Opts::parse();

setup_log();

if let Err(err) = process_cmd(opts).await {
error!("{:?}", err);
}
Expand Down Expand Up @@ -175,9 +177,10 @@ async fn init_projects(config: Init) -> Result<(), Box<dyn Error>> {
fs::create_dir_all(&config.path)?;

let workspace = PathBuf::from(&config.path);
let path = workspace.join(".quake.yaml");
let define = workspace.join("entries-define.yaml");
let path = workspace.join(EntryPaths::quake_config());
let define = workspace.join(EntryPaths::entries_define());

// todo: make default config to template
let quake_config = QuakeConfig {
workspace: config.path,
editor: "".to_string(),
Expand All @@ -187,7 +190,11 @@ async fn init_projects(config: Init) -> Result<(), Box<dyn Error>> {
};

fs::write(&path, serde_yaml::to_string(&quake_config)?)?;
debug!("create .quake.yaml in {:?}", &path.display());
debug!(
"create {:} in {:?}",
EntryPaths::quake_config(),
&path.display()
);

let todo_define = "
- type: todo
Expand Down
3 changes: 2 additions & 1 deletion src/pagedump.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use tracing::error;

use quake_core::entry::entry_paths::EntryPaths;
use quake_core::entry::EntryDefines;
Expand Down Expand Up @@ -93,7 +94,7 @@ fn dump_transflow(conf: &QuakeConfig) {
fs::write(out_path.join("gen_code.js"), content).unwrap();
}
Err(err) => {
println!("{:?}", err);
error!("{:?}", err);
}
}

Expand Down

0 comments on commit f7b7859

Please sign in to comment.