Sha256: 4fc2ecec2acf825cf963d35dab26d7b00d9ae5636596e32b04cfdeac203adb89

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'core/command'


module Nutella
  class Runs < Command
    @description = 'Displays list of runs for current project or all projects'
  
    def run(args=nil)

      # If invoked with "all" it will show all the runs under this instance of nutella
      if args[0]=='all'
        display_all_runs
      else
        # If current dir is not a nutella project, return
        return unless Nutella.current_project.exist?
        # Display list of runs for current nutella project
        display_project_runs
      end
    end
    
    
    private 
    
    
    def display_all_runs
      if Nutella.runlist.empty?
        console.info 'You are not running any projects'
      else
        console.info 'Currently running:'
        Nutella.runlist.runs_by_project.each { |run| console.info " #{run}" }
      end
    end
    
    def display_project_runs
      project_name = Nutella.current_project.config['name']
      runs = Nutella.runlist.runs_by_project project_name
      console.info "Currently running #{runs.length} instances of project #{project_name}:"
      runs.each do |run|
        run_id = run.dup
        run_id.slice! "#{project_name}_"
        if run_id.empty?
          console.info " #{project_name}"
        else
          console.info " #{run}"
        end
      end
    end
    
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nutella_framework-0.2.1 lib/core/commands/runs.rb
nutella_framework-0.2.0 lib/core/commands/runs.rb