Sha256: 5171e0a61f6f8bd4a08005b370816b2ab0fa0bff9cd11e963eb04b0e5d0d4033

Contents?: true

Size: 1.73 KB

Versions: 3

Compression:

Stored size: 1.73 KB

Contents

module Nucleon
module Plugin
class Command < Base

  #-----------------------------------------------------------------------------
  # Command plugin interface
  
  def normalize
    super
  end
  
  #---
   
  def to_s
    return build(export)
  end
  
  #-----------------------------------------------------------------------------
  # Property accessor / modifiers
  
  def command(default = '')
    return string(get(:command, default))
  end
  
  #---
  
  def command=command
    set(:command, string(command))
  end
  
  #---
  
  def args(default = [])
    return array(get(:args, default)) 
  end
  
  #---
  
  def args=args
    set(:args, array(args))
  end
  
  #---
  
  def flags(default = [])
    return array(get(:flags, default)) 
  end
  
  #---
  
  def flags=flags
    set(:flags, array(flags))
  end
  
  #---
  
  def data(default = {})
    return hash(get(:data, default)) 
  end
  
  #---
  
  def data=data
    set(:data, hash(data))
  end
  
  #---
  
  def subcommand=subcommand
    unless Util::Data.empty?(subcommand)
      set(:subcommand, new(hash(subcommand)))
    end
  end
  
  #-----------------------------------------------------------------------------
  # Command operations
  
  def build(components = {}, overrides = nil, override_key = false)
    logger.debug("Building command with #{components.inspect}")
    logger.debug("Overrides: #{overrides.inspect}")
    logger.debug("Override key: #{override_key}")
    
    return '' # Implement in sub classes
  end
  
  #---
  
  def exec(options = {}, overrides = nil)
    logger.debug("Executing command with #{options.inspect}")
    logger.debug("Overrides: #{overrides.inspect}")
    
    # Implement in sub classes (don't forget the yield!)
    return true
  end
end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nucleon-0.1.3 lib/core/plugin/command.rb
nucleon-0.1.2 lib/core/plugin/command.rb
nucleon-0.1.1 lib/core/plugin/command.rb