Adding all commands and boilerplate
This commit is contained in:
+8
-17
@@ -12,23 +12,14 @@ use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn init(files: Vec<PathBuf>, 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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user