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 |
# File 'lib/kosmos/user_interface.rb', line 10 def init(args) ksp_path = args.shift 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/kosmos/user_interface.rb', line 27 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
73 74 75 76 77 78 79 80 81 |
# File 'lib/kosmos/user_interface.rb', line 73 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
83 84 85 |
# File 'lib/kosmos/user_interface.rb', line 83 def server(args) Web::App.start! end |
.uninstall(args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kosmos/user_interface.rb', line 47 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) if package Util.log "Preparing to uninstall #{package.title} ..." Kosmos::Versioner.uninstall_package(ksp_path, package) Util.log "Done! Just uninstalled: #{package.title}." else Util.log "Error: Kosmos couldn't find any packages with the name #{package_name.inspect}." end end |