Add meetings, some bugfixes

This commit is contained in:
Jana Lemke 2023-05-24 11:11:12 +02:00
parent 15eca21e83
commit d36d209b1e
3 changed files with 22 additions and 1 deletions

View file

@ -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.

View file

@ -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<String> {
&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(())
}

View file

@ -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(())
}