|
|
|
@ -2,12 +2,38 @@
|
|
|
|
|
require "json"
|
|
|
|
|
require "./src/project.cr"
|
|
|
|
|
|
|
|
|
|
require "option_parser"
|
|
|
|
|
|
|
|
|
|
require "./altsrc/common.cr"
|
|
|
|
|
require "./altsrc/main.cr"
|
|
|
|
|
|
|
|
|
|
new_storage_dir = "./new-storage"
|
|
|
|
|
old_storage_dir = "./old-storage"
|
|
|
|
|
|
|
|
|
|
OptionParser.parse do |parser|
|
|
|
|
|
parser.on "-n new-storage-directory",
|
|
|
|
|
"--new-directory storage-directory",
|
|
|
|
|
"The new directory where to put converted files." do |opt|
|
|
|
|
|
new_storage_dir = opt
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
parser.on "-o old-storage-directory",
|
|
|
|
|
"--old-storage-directory directory",
|
|
|
|
|
"Old storage directory, to convert." do |opt|
|
|
|
|
|
old_storage_dir = opt
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
parser.on "-h", "--help", "Show this help" do
|
|
|
|
|
puts parser
|
|
|
|
|
puts "Default values are:"
|
|
|
|
|
pp! new_storage_dir
|
|
|
|
|
pp! old_storage_dir
|
|
|
|
|
exit 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 1. get the old list of projects
|
|
|
|
|
old_storage = Project.all "../storage/"
|
|
|
|
|
old_storage = Project.all old_storage_dir
|
|
|
|
|
|
|
|
|
|
# PROJECT: JSON.mapping({
|
|
|
|
|
# PROJECT: id: String,
|
|
|
|
@ -30,7 +56,7 @@ old_storage = Project.all "../storage/"
|
|
|
|
|
# TASKS: })
|
|
|
|
|
|
|
|
|
|
# 2. create the new storage
|
|
|
|
|
new_storage = TodoD::Storage.new "../new-storage/"
|
|
|
|
|
new_storage = TodoD::Storage.new new_storage_dir
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 3. for each project (old name for "list")
|
|
|
|
@ -91,7 +117,7 @@ old_storage.each do |old_project|
|
|
|
|
|
|
|
|
|
|
# 3. store the new task
|
|
|
|
|
tasks << newtask
|
|
|
|
|
new_storage.tasks[newtask.id] = newtask
|
|
|
|
|
new_storage.tasks << newtask
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# finally, create the list with all the parameters
|
|
|
|
@ -105,5 +131,5 @@ old_storage.each do |old_project|
|
|
|
|
|
pp! list
|
|
|
|
|
|
|
|
|
|
# finally, store the new list
|
|
|
|
|
new_storage.lists[list.id] = list
|
|
|
|
|
new_storage.lists << list
|
|
|
|
|
end
|
|
|
|
|