summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2018-12-18 17:49:45 -0500
committerJiayi Zhao <jeff.no.zhao@gmail.com>2018-12-18 17:49:45 -0500
commit6b99dbd322b67ecfdbc9156f5117cc5831bccd6e (patch)
treecb680e078672232bb878f06db6843b885be8c02f /src/main.rs
parentb2e7cf8b157883795e586f92cc267b1926de0dad (diff)
lots of changes
- make sort easier to use - SortType, SortStruct - make History a struct
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs81
1 files changed, 5 insertions, 76 deletions
diff --git a/src/main.rs b/src/main.rs
index c700d5c..b71dc22 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,5 @@
-#[macro_use]
-extern crate serde_derive;
+// #[macro_use]
+// extern crate serde_derive;
extern crate ncurses;
extern crate toml;
@@ -14,87 +14,16 @@ mod joshuto;
const PROGRAM_NAME : &str = "joshuto";
const CONFIG_FILE : &str = "joshuto.toml";
-/*
-pub struct joshuto_win {
- win : ncurses::WINDOW,
- offset : usize,
- row_size : i32,
- col_size : i32,
-}
-*/
-
-#[derive(Debug, Deserialize)]
-pub struct JoshutoConfig {
- color_scheme : Option<String>,
- show_hidden : Option<bool>,
- sort_method : Option<String>,
- column_ratio : Option<[usize; 3]>,
-// keymaps: Option<JoshutoKeymaps>,
- mimetypes : Option<BTreeMap<String, Vec<String>>>,
-}
-
-#[derive(Debug, Deserialize)]
-pub struct JoshutoKeymaps {
- up : i32,
-}
-
-fn generate_default_config() -> JoshutoConfig
-{
- JoshutoConfig {
- show_hidden: None,
- color_scheme: None,
- sort_method: None,
- column_ratio : None,
-// keymaps: None,
- mimetypes: None,
- }
-}
-
-fn read_config() -> Option<JoshutoConfig>
-{
- let dirs = xdg::BaseDirectories::with_profile(PROGRAM_NAME, "").unwrap();
- match dirs.find_config_file(CONFIG_FILE) {
- Some(config_path) => {
- println!("config_path: {:?}", config_path);
- let config_contents = fs::read_to_string(&config_path).unwrap();
-
- match toml::from_str(&config_contents) {
- Ok(config) => {
- Some(config)
- },
- Err(e) => {
- eprintln!("{}", e);
- None
- }
- }
- },
- None => {
- None
- }
- }
-}
-
-fn get_config() -> JoshutoConfig
-{
- match read_config() {
- Some(config) => {
- config
- }
- None => {
- generate_default_config()
- }
- }
-}
-
fn main()
{
let args: Vec<String> = env::args().collect();
println!("args:\n{:?}", args);
- let mut config = get_config();
+ let config = joshuto::config::JoshutoRawConfig::new();
+ let config = config.to_config();
println!("config:\n{:?}", config);
- joshuto::run(&mut config);
+ joshuto::run(config);
}