Windows.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. module RimeDeploy
  2. class WindowsJobGroup < JobGroup
  3. Store.config_path = ENV["APPDATA"] + '\\Rime'
  4. def clear_screen
  5. system("cls")
  6. end
  7. class CheckInstallRimeJob < Job
  8. def call
  9. puts "==== Rime auto deploy ====".green
  10. puts "Before Check Rime Installed Staus".yellow
  11. tips = <<-TIP
  12. Windows system doesn't have it's own package manager, so make sure you had installed Rime before.
  13. You can download Rime from: https://rime.im/download/
  14. TIP
  15. puts tips
  16. puts ""
  17. ChooseSession.new(
  18. [
  19. ["I have installed Rime. Let's go next.", -> {}],
  20. [
  21. "I'll quit first.After installed Rime by myself then run this program again.",
  22. -> { exit 0 }
  23. ]
  24. ]
  25. ).call
  26. sleep 1
  27. return :next
  28. end
  29. end
  30. class BackupRimeConfigJob < Job
  31. def call
  32. puts intro
  33. system(
  34. "move #{Store.config_path} #{Store.config_path}.#{Time.now.to_i}.old"
  35. )
  36. sleep 1
  37. return :next
  38. end
  39. end
  40. class CloneConfigJob < Job
  41. def call
  42. puts intro
  43. system(
  44. "git clone #{Config::RIME_CONFIG_REPO} #{Store.config_path}"
  45. )
  46. sleep 1
  47. return :next
  48. end
  49. end
  50. class CopyCustomConfigJob < Job
  51. def call
  52. puts intro
  53. system("copy .\\custom\\*.yaml #{Store.config_path}")
  54. sleep 1
  55. return :next
  56. end
  57. end
  58. class FinishedJob < Job
  59. def call
  60. puts ""
  61. puts "Tips: When finished all jobs. You need to do follow:".yellow
  62. puts "1) Restart system."
  63. puts "2) open Rime input method setting pane and click " +
  64. "DEPLOY".yellow + " button."
  65. puts "Enjoy~"
  66. puts "more info:".yellow
  67. puts "Config path: #{Store.config_path}"
  68. return :next
  69. end
  70. end
  71. self.before_jobs = [CheckInstallRimeJob]
  72. self.jobs = [BackupRimeConfigJob, CloneConfigJob, CopyCustomConfigJob]
  73. self.after_jobs = [FinishedJob]
  74. self.upgrade_jobs = [
  75. Upgrade::UpgradeRimeAutoDeployJob,
  76. Upgrade::UpgradeRimeConfigJob
  77. ]
  78. end
  79. end