conversion script updated with the author user id CLI parameter.

master
Philippe PITTOLI 2020-01-16 20:57:17 +01:00
parent 0487a796f3
commit c159ac6382
1 changed files with 11 additions and 1 deletions

View File

@ -9,6 +9,7 @@ require "./altsrc/main.cr"
new_storage_dir = "./new-storage" new_storage_dir = "./new-storage"
old_storage_dir = "./old-storage" old_storage_dir = "./old-storage"
user_id = 1001
OptionParser.parse do |parser| OptionParser.parse do |parser|
parser.on "-n new-storage-directory", parser.on "-n new-storage-directory",
@ -17,6 +18,11 @@ OptionParser.parse do |parser|
new_storage_dir = opt new_storage_dir = opt
end end
parser.on "-u user-id",
"--user-id user-id",
"User id of the author of all lists." do |opt|
user_id = opt.to_i
end
parser.on "-o old-storage-directory", parser.on "-o old-storage-directory",
"--old-storage-directory directory", "--old-storage-directory directory",
"Old storage directory, to convert." do |opt| "Old storage directory, to convert." do |opt|
@ -28,6 +34,7 @@ OptionParser.parse do |parser|
puts "Default values are:" puts "Default values are:"
pp! new_storage_dir pp! new_storage_dir
pp! old_storage_dir pp! old_storage_dir
pp! user_id
exit 0 exit 0
end end
end end
@ -65,9 +72,11 @@ new_storage = TodoD::Storage.new new_storage_dir
# 3.3. create and store the new list # 3.3. create and store the new list
class User class User
property uid : Int32 = 1002 property uid : Int32 = 1001
end end
old_storage.each do |old_project| old_storage.each do |old_project|
puts "" puts ""
puts "" puts ""
@ -123,6 +132,7 @@ old_storage.each do |old_project|
# finally, create the list with all the parameters # finally, create the list with all the parameters
u = User.new u = User.new
u.uid = user_id
list = TodoD::List.new old_project.name, u, extra_properties list = TodoD::List.new old_project.name, u, extra_properties
list.id = old_project.id list.id = old_project.id
list.tasks = tasks.map &.id list.tasks = tasks.map &.id