+--- Opens the active plan file
+function Plan.open(force_template)
+ local plan_path = vim.fn.expand(Configuration.configuration.plan.plan_file)
+ local plan_parent = Util.directory_name(plan_path)
+ Util.ensure_directory_exists(plan_parent)
+ open_or_create_from_template(plan_path, force_template)
+end
+
+--- Capture a new plan file and archive the current one
+function Plan.capture()
+ local fs = vim.loop
+
+ local plan_path = vim.fn.expand(Configuration.configuration.plan.plan_file)
+ local plan_parent = Util.directory_name(plan_path)
+ Util.ensure_directory_exists(plan_parent)
+
+ local archive_path = Configuration.path_for(Configuration.configuration.plan.archive)
+ Util.ensure_directory_exists(archive_path)
+
+ if fs.fs_stat(plan_path) then
+ local archive_filename = os.date('%Y-%m-%d') .. '.md'
+ copy(plan_path, Util.join(archive_path, archive_filename))
+ end
+
+ Plan.open(true)
+end
+
+return Plan