diff --git a/src/commit.rs b/src/commit.rs new file mode 100644 index 0000000..546ec1f --- /dev/null +++ b/src/commit.rs @@ -0,0 +1,24 @@ +use crate::TOUR_DIR; +use std::fs; +use std::io::Write; +use std::path::PathBuf; + +pub fn commit(files: Vec, message: String) -> Result<(), std::io::Error> { + // let files = files.iter().map(|p| p.as_ref()).collect(); + // + // let dir = std::fs::read_dir(format!("{}/steps", TOUR_DIR))?; + // + // // USE /steps to find number of next step + // // let step_number = + // + // fs::create_dir_all(format!("{}/{}", TOUR_DIR, "steps/0/files"))?; + // + // // Copy files listed by command to step 0 + // let dest = format!("{}/steps/0/files/", TOUR_DIR); + // crate::utils::copy_files(files, dest.as_ref())?; + // + // // Copy message + // let mut message_file = fs::File::create(format!("{}/steps/{}/message", TOUR_DIR, step_number))?; + // write!(message_file, "{}", message)?; + Ok(()) +} diff --git a/src/end.rs b/src/end.rs new file mode 100644 index 0000000..08c5d9e --- /dev/null +++ b/src/end.rs @@ -0,0 +1,3 @@ +pub fn end(message: String) -> Result<(), std::io::Error> { + Ok(()) +} diff --git a/src/init.rs b/src/init.rs index 0ea1f3f..38ef83e 100644 --- a/src/init.rs +++ b/src/init.rs @@ -12,23 +12,14 @@ use std::io::Write; use std::path::PathBuf; pub fn init(files: Vec, message: String) -> Result<(), std::io::Error> { - // Convert PathBuf to &Path - let files = files.iter().map(|p| p.as_path()).collect(); - - // Check TOUR_DIR exists (it shouldn't because user calls init) - if fs::exists(TOUR_DIR)? { - panic!("{} folder exists", TOUR_DIR); - } - // Create dir recursively - fs::create_dir_all(format!("{}/{}", TOUR_DIR, "steps/0/files"))?; - - // Copy files listed by command to step 0 - let dest = format!("{}/steps/0/files/", TOUR_DIR); - copy_files(files, dest.as_ref())?; - - // Copy message to step 0 - let mut message_file = File::create("./.tour/steps/0/message")?; - write!(message_file, "{}", message)?; + // // Convert PathBuf to &Path + // let files = files.iter().map(|p| p.as_path()).collect(); + // + // // Check TOUR_DIR exists (it shouldn't because user calls init) + // if fs::exists(TOUR_DIR)? { + // panic!("{} folder exists", TOUR_DIR); + // } + // // Create dir recursively Ok(()) } diff --git a/src/main.rs b/src/main.rs index 024a447..d814ad1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,10 +3,14 @@ use std::error::Error; use std::path::{Path, PathBuf}; mod commit; +mod end; mod init; +mod next; +mod prev; mod utils; const TOUR_DIR: &str = "./.tour"; +const DEFAULT_SESSION: &str = "./.tour/session"; #[derive(Parser)] #[command(author, version, about, long_about = None)] @@ -34,7 +38,7 @@ enum Commands { // Finish the tour End { #[arg(short, long, value_name = "MESSAGE")] - message: Option, + message: String, }, // Go to next step of tour @@ -54,6 +58,9 @@ fn main() -> Result<(), Box> { match args.command { Some(Commands::Init { files, message }) => crate::init::init(files, message)?, Some(Commands::Commit { files, message }) => crate::commit::commit(files, message)?, + Some(Commands::End { message }) => crate::end::end(message)?, + Some(Commands::Next { n }) => crate::next::next(n)?, + Some(Commands::Prev { n }) => crate::prev::prev(n)?, _ => println!("command not found"), } Ok(()) diff --git a/src/next.rs b/src/next.rs new file mode 100644 index 0000000..53baba9 --- /dev/null +++ b/src/next.rs @@ -0,0 +1,3 @@ +pub fn next(n: Option) -> Result<(), std::io::Error> { + Ok(()) +} diff --git a/src/prev.rs b/src/prev.rs new file mode 100644 index 0000000..570fb85 --- /dev/null +++ b/src/prev.rs @@ -0,0 +1,3 @@ +pub fn prev(n: Option) -> Result<(), std::io::Error> { + Ok(()) +}