Class: AppStore::Emigrant::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/app-store-emigrant/cli.rb

Overview

Represents the command line interface

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Initializes CLI instance with given arguments



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
40
# File 'lib/app-store-emigrant/cli.rb', line 11

def initialize args
  
  # Extract the path (if any)
  path, = args
  
  # Use the default library on this system when no path is specified
  library = path ? Library.new(path) : Library.default
  
  # Load cloud data in bulk
  library.clouddata!
  
  # Loop through all applications
  library.apps.each do |app|
    
    if app.valid?
      
      # Print their name, version and whether it's outdated
      print app.name + ' @ ' + "v#{app.version}".foreground(app.outdated? ? :red : :green)
      if app.outdated?
        print " (v#{app.cloudversion} available in the cloud)" 
      end
    else
      print app.filename + ' is invalid (metadata, id or name missing)'
    end
    
    puts
    
  end
  
end