diff options
author | Melody Horn / boringcactus <melody@boringcactus.com> | 2021-06-13 21:05:56 -0600 |
---|---|---|
committer | Melody Horn / boringcactus <melody@boringcactus.com> | 2021-06-13 21:05:56 -0600 |
commit | 19b851c71ee8c7499046936771446e6ae6e60c16 (patch) | |
tree | 122233034491937ff3c5aaf0fb5fa344744d4397 /src | |
parent | d30b5db6f3eabd2a550ef05e6203d3c7ef19e9c7 (diff) | |
download | tosin-19b851c71ee8c7499046936771446e6ae6e60c16.tar.gz tosin-19b851c71ee8c7499046936771446e6ae6e60c16.zip |
finish passing the tutorial 1 tests
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/tosin-admin.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/bin/tosin-admin.rs b/src/bin/tosin-admin.rs index 3eb57a1..6408337 100644 --- a/src/bin/tosin-admin.rs +++ b/src/bin/tosin-admin.rs @@ -1,6 +1,7 @@ use std::env::set_current_dir; use std::fs; use std::io::Write as _; +use std::path::Path; use std::process::Command; use structopt::StructOpt; @@ -26,11 +27,37 @@ fn settings() -> Settings { tosin::main!(urls(), settings()); "#; +const APP_MOD: &str = r#" +pub mod urls; +pub mod views; + +pub use urls::urls; +"#; +const APP_URLS: &str = r#" +use tosin::urls::{UrlMap, url_map}; + +use super::views; + +pub fn urls() -> UrlMap { + todo!("fill in URL map") +} +"#; +const APP_VIEWS: &str = r#" +use tosin::http::{Reply, Response}; + +todo!("write some views"); +"#; + #[derive(StructOpt, Debug)] enum Opt { /// Start a new project/site (can contain multiple apps) StartProject { name: Option<String>, + }, + + /// Start a new app + StartApp { + name: String, } } @@ -66,5 +93,17 @@ fn main() { } } } + Opt::StartApp { name } => { + // TODO make this more robust + if fs::metadata("Cargo.toml").is_ok() { + let app_folder = Path::new("src").join(name); + fs::create_dir(&app_folder).unwrap(); + fs::write(app_folder.join("mod.rs"), APP_MOD).unwrap(); + fs::write(app_folder.join("urls.rs"), APP_URLS).unwrap(); + fs::write(app_folder.join("views.rs"), APP_VIEWS).unwrap(); + } else { + todo!("new standalone app crate maybe??") + } + } } } |