diff options
Diffstat (limited to 'note_tools/tomorrow.py')
-rw-r--r-- | note_tools/tomorrow.py | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/note_tools/tomorrow.py b/note_tools/tomorrow.py index 2198a3b..21b1fd5 100644 --- a/note_tools/tomorrow.py +++ b/note_tools/tomorrow.py | |||
@@ -3,25 +3,15 @@ import os | |||
3 | from datetime import timedelta | 3 | from datetime import timedelta |
4 | import sublime | 4 | import sublime |
5 | import sublime_plugin | 5 | import sublime_plugin |
6 | from typing import Optional | ||
6 | 7 | ||
7 | class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand): | 8 | class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand): |
8 | def run(self): | 9 | def run(self): |
9 | self.date = self.get_date() + timedelta(days=1) | 10 | self.date += timedelta(days=1) |
11 | project_data = self.window.project_data() | ||
10 | 12 | ||
11 | notes_path = self.get_notes_path(self.window.project_data()) | 13 | def callback(success: bool, message: Optional[str], file_path: Optional[str]): |
12 | 14 | if not success: | |
13 | if notes_path: | 15 | sublime.message_dialog(message) |
14 | year, month = self.get_date_parts() | ||
15 | directory = os.path.join(notes_path, year, month) | ||
16 | os.makedirs(directory, exist_ok=True) | ||
17 | file_path = os.path.join(directory, self.file_name()) | ||
18 | |||
19 | # Check if file already exists | ||
20 | if os.path.exists(file_path): | ||
21 | sublime.message_dialog(f"The file '{self.file_name()}' already exists.") | ||
22 | else: | ||
23 | self.write_file_heading(file_path) | ||
24 | |||
25 | else: | ||
26 | sublime.message_dialog("No 'Notes' directory found in the project. Please add a 'Notes' folder.") | ||
27 | 16 | ||
17 | self.create_note(project_data=project_data, callback=callback) | ||