Module: Kosmos::UserInterface
- Defined in:
- lib/kosmos/user_interface.rb
Class Method Summary collapse
- .init(args) ⇒ Object
- .install(args) ⇒ Object
- .list(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/kosmos/user_interface.rb', line 10 def init(args) ksp_path = extract_ksp_path_from_args(args) unless ksp_path Util.log <<-EOS.undent Error: You did not specify what folder you keep KSP in. Before doing anything else, please execute the command: kosmos init ksp-folder Where "ksp-folder" is the name of the folder where you keep KSP. EOS return end Util.log "Initializing Kosmos into #{ksp_path} (This will take a sec) ..." Kosmos::Versioner.init_repo(ksp_path) Kosmos.save_ksp_path(ksp_path) Util.log <<-EOS.undent Done! You're ready to begin installing mods. Install your first mod by running the command: kosmos install [name-of-the-mod] EOS end |
.install(args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/kosmos/user_interface.rb', line 41 def install(args) return unless check_initialized! ksp_path = Kosmos.load_ksp_path packages = load_packages(args) return unless packages return unless check_installed_packages(ksp_path, packages) Util.log "Kosmos is about to install #{packages.count} package(s):" pretty_print_list(packages.map(&:title)) packages.each do |package| Util.log "Installing package #{package.title} ..." package.new.install!(ksp_path) Util.log "Done!" end end |
.list(args) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/kosmos/user_interface.rb', line 98 def list(args) return unless check_initialized! ksp_path = Kosmos.load_ksp_path packages = Kosmos::Versioner.installed_packages(ksp_path) Util.log "You have installed #{packages.length} mod(s) using Kosmos:" pretty_print_list(packages) end |
.server(args) ⇒ Object
108 109 110 |
# File 'lib/kosmos/user_interface.rb', line 108 def server(args) Web::App.start! end |
.uninstall(args) ⇒ Object
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 93 94 95 96 |
# File 'lib/kosmos/user_interface.rb', line 61 def uninstall(args) return unless check_initialized! ksp_path = Kosmos.load_ksp_path package_name = args.shift unless package_name Util.log <<-EOS.undent Error: You need to specify what package to uninstall. Example: kosmos uninstall name-of-the-mod" EOS return end package = Kosmos::Package.find(package_name) installed_packages = Kosmos::Versioner.installed_packages(ksp_path) if !package Util.log "Error: Kosmos couldn't find any packages with the name #{package_name.inspect}." elsif !installed_packages.include?(package.title) Util.log <<-EOS.undent Error: #{package.title} is not currently installed. There are three reasons you may get this error: 1. You have already uninstalled #{package.title}. 2. You have never previously installed #{package.title}. 3. You did not use Kosmos to install #{package.title}. EOS else Util.log "Preparing to uninstall #{package.title} ..." Kosmos::Versioner.uninstall_package(ksp_path, package) Util.log "Done! Just uninstalled: #{package.title}." end end |