Преглед на файлове

Change the options file to toml.

Lee Morgan преди 3 месеца
родител
ревизия
d53d211fe3
променени са 4 файла, в които са добавени 46 реда и са изтрити 7 реда
  1. 12 0
      src/build_dev.rs
  2. 6 6
      src/create.rs
  3. 6 1
      src/main.rs
  4. 22 0
      src/routes_map.rs

+ 12 - 0
src/build_dev.rs

@@ -0,0 +1,12 @@
+use std::path::Path;
+
+pub fn build_dev() {
+    //Create path for routes dir
+    //
+    //Recursive build list of files (FileType)
+    //
+    //Bundle each file
+    //Create route for index files
+
+
+}

+ 6 - 6
src/create.rs

@@ -9,16 +9,16 @@ pub fn create(project_name: String) {
     fs::create_dir(path.join("routes")).expect(fail_msg);
     fs::create_dir(path.join("assets")).expect(fail_msg);
     fs::write(path.join(".gitignore"), "target/").expect(fail_msg);
-    fs::write(path.join("neovan.yml"), create_settings()).expect(fail_msg);
+    fs::write(path.join("neovan.toml"), create_settings()).expect(fail_msg);
     fs::write(path.join("routes").join("index.neovan"), hello_world_html()).expect(fail_msg);
 }
 
 fn create_settings() -> String {
-    r#"production: false
-routes_dir: routes
-build_dir: .build
-assets_dir: assets
-assets_route: /assets
+    r#"[options]
+routes_dir = "routes"
+build_dir = ".build"
+assets_dir = "assets"
+assets_route = "/assets"
 "#.to_string()
 }
 

+ 6 - 1
src/main.rs

@@ -1,7 +1,11 @@
 use clap::Parser;
-use crate::create::create;
+use crate::{
+    create::create,
+    build_dev::build_dev
+};
 
 mod create;
+mod build_dev;
 
 #[derive(Parser)]
 #[command(version, about, long_about = None)]
@@ -15,6 +19,7 @@ fn main() {
 
     match cli.operation.as_str() {
         "create" => create(cli.arg1),
+        "build-dev" => build_dev(),
         a => eprintln!("Unknown command: {}", a)
     }
 }

+ 22 - 0
src/routes_map.rs

@@ -0,0 +1,22 @@
+use std::path::Path;
+use std::fs;
+
+pub enum FileType {
+    HtmlIndex(Path),
+    NeovanIndex(Path),
+    Component(Path)
+}
+
+impl FileType {
+    pub fn build(dir: Path) -> FileStructure {
+        let items = fs::read_dir(dir).expect("Create failed");
+
+        items.
+            .map(|f| {
+                match f {
+                    println!("{}", f);
+                }
+            })
+            .collect()
+    }
+}