From c159ac638252b943573cf0e4153ca8ef7620cbf7 Mon Sep 17 00:00:00 2001
From: Philippe PITTOLI
Date: Thu, 16 Jan 2020 20:57:17 +0100
Subject: [PATCH] conversion script updated with the author user id CLI
parameter.
---
conversion.cr | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/conversion.cr b/conversion.cr
index 26f6e73..4da7d7a 100644
--- a/conversion.cr
+++ b/conversion.cr
@@ -9,6 +9,7 @@ require "./altsrc/main.cr"
new_storage_dir = "./new-storage"
old_storage_dir = "./old-storage"
+user_id = 1001
OptionParser.parse do |parser|
parser.on "-n new-storage-directory",
@@ -17,6 +18,11 @@ OptionParser.parse do |parser|
new_storage_dir = opt
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",
"--old-storage-directory directory",
"Old storage directory, to convert." do |opt|
@@ -28,6 +34,7 @@ OptionParser.parse do |parser|
puts "Default values are:"
pp! new_storage_dir
pp! old_storage_dir
+ pp! user_id
exit 0
end
end
@@ -65,9 +72,11 @@ new_storage = TodoD::Storage.new new_storage_dir
# 3.3. create and store the new list
class User
- property uid : Int32 = 1002
+ property uid : Int32 = 1001
end
+
+
old_storage.each do |old_project|
puts ""
puts ""
@@ -123,6 +132,7 @@ old_storage.each do |old_project|
# finally, create the list with all the parameters
u = User.new
+ u.uid = user_id
list = TodoD::List.new old_project.name, u, extra_properties
list.id = old_project.id
list.tasks = tasks.map &.id