Add meetings, some bugfixes
This commit is contained in:
parent
fa4381e35c
commit
ae88518152
4 changed files with 23 additions and 1 deletions
1
notes.md
1
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue