diff --git a/notes.md b/notes.md index 9814c63..7df758f 100644 --- a/notes.md +++ b/notes.md @@ -1,5 +1,6 @@ # Things to do next - `check` complains about some of the defaults. Make sure default settings conform with opinions of `check` +- create add-meeting to current course - refactor to move functionality like rofi to shell scripts Instead provide more scriptable functionality diff --git a/src/config.rs b/src/config.rs index 07af429..6004a2f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -34,6 +34,9 @@ pub struct Config { /// The location of the link pointing to the current course. /// This is treated as the single source of truth as to what the current course is. /// This needs to be a absolute path. + /// This also should not end in a slash + /// (because Unix convention is that that means the location the link points to + /// and not the link itself). #[serde(deserialize_with = "ensure_absolute_path")] pub link_path: PathBuf, /// The folder under which all other folders of "courses" are located. diff --git a/src/courses.rs b/src/courses.rs index 8bc0e99..28cccfb 100644 --- a/src/courses.rs +++ b/src/courses.rs @@ -38,7 +38,7 @@ pub struct Meeting { impl Course { pub fn current() -> Self { - Self::from_path(&CONFIG.link_path) + Self::from_path(&CONFIG.link_path.canonicalize().unwrap()) } // TODO: make this the single method to read a Course @@ -61,6 +61,12 @@ impl Course { } } + pub fn write(self) { + todo!(); + } + + pub fn pretty_print(&self) {} + /// Get a reference to the course's semesters. pub fn semesters(&self) -> &Vec { &self.semesters @@ -84,7 +90,10 @@ impl Course { pub fn set(&self) -> Result<()> { // TODO: make sure this is actually a link, and we are not removing some other file of the user + eprintln!("Trying to remove symlink at {:?}", &CONFIG.link_path); remove_file(&CONFIG.link_path)?; + eprintln!("Removed symlink"); + eprintln!("linking {:?} to {:?}", &self.path, &CONFIG.link_path); symlink(&self.path, &CONFIG.link_path)?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index e55427c..7d44408 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,17 +19,23 @@ struct Cli { #[derive(StructOpt)] enum Command { ShowConfig, + #[structopt(name = "show")] + ShowCurrentCourse, ListCourses(ListOptions), ListLectures(ListOptions), SelectCourse(ListOptions), SelectLecture, AddCourse(Course), + AddMeeting(Meeting), AddLecture, Init, Check(ListOptions), Meetings(ListOptions), } +#[derive(StructOpt)] +struct NewMeeting {} + // #[derive(StructOpt)] // struct ObjectStruct { // #[structopt(subcommand)] @@ -62,6 +68,9 @@ fn main() -> Result<()> { Command::Check(list_options) => Course::check(&list_options)?, Command::Meetings(options) => rofi::select_meeting(&options)?, Command::ShowConfig => println!("{:?}", *CONFIG), + Command::AddMeeting(meeting) => (), + Command::ShowCurrentCourse => println!("{:?}", Course::current()), + //Course::current().meetings.push(meeting), }; Ok(()) }