diff options
Diffstat (limited to 'note_tools/tomorrow.py')
-rw-r--r-- | note_tools/tomorrow.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/note_tools/tomorrow.py b/note_tools/tomorrow.py new file mode 100644 index 0000000..2198a3b --- /dev/null +++ b/note_tools/tomorrow.py | |||
@@ -0,0 +1,27 @@ | |||
1 | from . import NoteBaseCommand | ||
2 | import os | ||
3 | from datetime import timedelta | ||
4 | import sublime | ||
5 | import sublime_plugin | ||
6 | |||
7 | class NewNoteForTomorrowCommand(NoteBaseCommand, sublime_plugin.WindowCommand): | ||
8 | def run(self): | ||
9 | self.date = self.get_date() + timedelta(days=1) | ||
10 | |||
11 | notes_path = self.get_notes_path(self.window.project_data()) | ||
12 | |||
13 | if notes_path: | ||
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 | |||