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
|
# Things to do next
|
||||||
- `check` complains about some of the defaults. Make sure default settings conform with opinions of `check`
|
- `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
|
- refactor to move functionality like rofi to shell scripts
|
||||||
Instead provide more scriptable functionality
|
Instead provide more scriptable functionality
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,9 @@ pub struct Config {
|
||||||
/// The location of the link pointing to the current course.
|
/// 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 is treated as the single source of truth as to what the current course is.
|
||||||
/// This needs to be a absolute path.
|
/// 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")]
|
#[serde(deserialize_with = "ensure_absolute_path")]
|
||||||
pub link_path: PathBuf,
|
pub link_path: PathBuf,
|
||||||
/// The folder under which all other folders of "courses" are located.
|
/// The folder under which all other folders of "courses" are located.
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ pub struct Meeting {
|
||||||
|
|
||||||
impl Course {
|
impl Course {
|
||||||
pub fn current() -> Self {
|
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
|
// 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.
|
/// Get a reference to the course's semesters.
|
||||||
pub fn semesters(&self) -> &Vec<String> {
|
pub fn semesters(&self) -> &Vec<String> {
|
||||||
&self.semesters
|
&self.semesters
|
||||||
|
|
@ -84,7 +90,10 @@ impl Course {
|
||||||
|
|
||||||
pub fn set(&self) -> Result<()> {
|
pub fn set(&self) -> Result<()> {
|
||||||
// TODO: make sure this is actually a link, and we are not removing some other file of the user
|
// 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)?;
|
remove_file(&CONFIG.link_path)?;
|
||||||
|
eprintln!("Removed symlink");
|
||||||
|
eprintln!("linking {:?} to {:?}", &self.path, &CONFIG.link_path);
|
||||||
symlink(&self.path, &CONFIG.link_path)?;
|
symlink(&self.path, &CONFIG.link_path)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,23 @@ struct Cli {
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
enum Command {
|
enum Command {
|
||||||
ShowConfig,
|
ShowConfig,
|
||||||
|
#[structopt(name = "show")]
|
||||||
|
ShowCurrentCourse,
|
||||||
ListCourses(ListOptions),
|
ListCourses(ListOptions),
|
||||||
ListLectures(ListOptions),
|
ListLectures(ListOptions),
|
||||||
SelectCourse(ListOptions),
|
SelectCourse(ListOptions),
|
||||||
SelectLecture,
|
SelectLecture,
|
||||||
AddCourse(Course),
|
AddCourse(Course),
|
||||||
|
AddMeeting(Meeting),
|
||||||
AddLecture,
|
AddLecture,
|
||||||
Init,
|
Init,
|
||||||
Check(ListOptions),
|
Check(ListOptions),
|
||||||
Meetings(ListOptions),
|
Meetings(ListOptions),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(StructOpt)]
|
||||||
|
struct NewMeeting {}
|
||||||
|
|
||||||
// #[derive(StructOpt)]
|
// #[derive(StructOpt)]
|
||||||
// struct ObjectStruct {
|
// struct ObjectStruct {
|
||||||
// #[structopt(subcommand)]
|
// #[structopt(subcommand)]
|
||||||
|
|
@ -62,6 +68,9 @@ fn main() -> Result<()> {
|
||||||
Command::Check(list_options) => Course::check(&list_options)?,
|
Command::Check(list_options) => Course::check(&list_options)?,
|
||||||
Command::Meetings(options) => rofi::select_meeting(&options)?,
|
Command::Meetings(options) => rofi::select_meeting(&options)?,
|
||||||
Command::ShowConfig => println!("{:?}", *CONFIG),
|
Command::ShowConfig => println!("{:?}", *CONFIG),
|
||||||
|
Command::AddMeeting(meeting) => (),
|
||||||
|
Command::ShowCurrentCourse => println!("{:?}", Course::current()),
|
||||||
|
//Course::current().meetings.push(meeting),
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue