Module: Kmc::UserInterface
- Defined in:
- lib/kmc/user_interface.rb
Class Method Summary collapse
- .init(args) ⇒ Object
- .install(args) ⇒ Object
- .list(args) ⇒ Object
- .refresh(args) ⇒ Object
- .server(args) ⇒ Object
- .uninstall(args) ⇒ Object
Class Method Details
.init(args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/kmc/user_interface.rb', line 10 def init(args) ksp_path = extract_ksp_path_from_args(args) unless ksp_path Util.log " Error: You did not specify what folder you keep KSP in.\n\n Before doing anything else, please execute the command:\n\n kmc init ksp-folder\n\n Where \"ksp-folder\" is the name of the folder where you keep KSP.\n EOS\n\n return\n end\n\n Util.log \"Initializing KMC into \#{ksp_path} (This will take a sec) ...\"\n\n Kmc::Versioner.init_repo(ksp_path)\n Kmc::Configuration.save_ksp_path(ksp_path)\n\n Util.log <<-EOS.undent\n Done! You're ready to begin installing mods.\n\n Install your first mod by running the command:\n\n kmc install [name-of-the-mod]\n EOS\nend\n".undent |
.install(args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kmc/user_interface.rb', line 41 def install(args) return unless check_initialized! ksp_path = Kmc::Configuration.load_ksp_path packages = load_packages(args) return unless packages return unless check_installed_packages(ksp_path, packages) Util.log "KMC is about to install #{packages.count} package(s):" pretty_print_list(packages.map(&:title)) Package.install_packages!(ksp_path, packages) end |
.list(args) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/kmc/user_interface.rb', line 94 def list(args) return unless check_initialized! ksp_path = Kmc::Configuration.load_ksp_path packages = Kmc::Versioner.installed_packages(ksp_path) Util.log "You have installed #{packages.length} mod(s) using KMC:" pretty_print_list(packages.map(&:title)) end |
.refresh(args) ⇒ Object
104 105 106 107 108 |
# File 'lib/kmc/user_interface.rb', line 104 def refresh(args) Util.log "Getting the most up-to-date packages for KMC ..." Kmc::Refresher.update_packages! Util.log "Done. The KMC packages you have are all up-to-date." end |
.server(args) ⇒ Object
110 111 112 |
# File 'lib/kmc/user_interface.rb', line 110 def server(args) Web::App.start! end |
.uninstall(args) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kmc/user_interface.rb', line 57 def uninstall(args) return unless check_initialized! ksp_path = Kmc::Configuration.load_ksp_path package_name = args.shift unless package_name Util.log " Error: You need to specify what package to uninstall. Example:\n kmc uninstall name-of-the-mod\"\n EOS\n\n return\n end\n\n package = Kmc::Package.find(package_name)\n installed_packages = Kmc::Versioner.installed_packages(ksp_path)\n\n if !package\n Util.log \"Error: KMC couldn't find any packages with the name \#{package_name.inspect}.\"\n elsif !installed_packages.include?(package.title)\n Util.log <<-EOS.undent\n Error: \#{package.title} is not currently installed.\n\n There are three reasons you may get this error:\n\n 1. You have already uninstalled \#{package.title}.\n 2. You have never previously installed \#{package.title}.\n 3. You did not use KMC to install \#{package.title}.\n EOS\n else\n Util.log \"Preparing to uninstall \#{package.title} ...\"\n Kmc::Versioner.uninstall_package(ksp_path, package)\n Util.log \"Done! Just uninstalled: \#{package.title}.\"\n end\nend\n".undent |