Sha256: 98ee1545c951d0180a7239f2002ddbf2a1e85833df7e9a5f21498a688312cbdd

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'core/command'


module Nutella
  class Runs < Command
    @description = "Displays list of all the runs, you can filter by passing a project id"
  
    def run(args=nil)
      # If invoked with "--all" it will show all the runs under this instance of nutella
      if args[0]=="--all"
        displayGlobalRuns
      else
        # Is current directory a nutella prj?
        if !Nutella.currentProject.exist?
          return
        end
        displayProjectRuns     
      end
    end
    
    
    private 
    
    
    def displayGlobalRuns
      if Nutella.runlist.empty?
        console.info "You are not running any projects"
      else
        console.info "Currently running:"
        Nutella.runlist.to_a.each { |run| console.info " #{run}" }   
      end
    end
    
    
    def displayProjectRuns
      project_name = Nutella.currentProject.config["name"]
      runs = Nutella.runlist.to_a project_name
      if runs.empty?
        console.info "Currently running #{runs.length} instances of project #{project_name}"
        return
      end
      printProjectRuns(project_name, runs)
    end
    
    
    def printProjectRuns(project_name, runs)
      console.info "Currently running #{runs.length} instances of project #{project_name}:"
      runs.to_a.each do |run| 
        run.slice! "#{project_name}_"
        if run.empty? 
          console.info "progetto (default)"
        else
          console.info " #{run}" 
        end
      end
    end
    
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nutella_framework-0.1.2 lib/core/commands/runs.rb