Sha256: aee7f75d66ad77c5667ae098323ff389d62276031642c86aba60ee824036d065

Contents?: true

Size: 1.85 KB

Versions: 16

Compression:

Stored size: 1.85 KB

Contents

module Nucleon
module Plugin
class Command < Nucleon.plugin_class(:nucleon, :base)

  def self.register_ids
    [ :command, :args, :flags, :data, :subcommand ]
  end
  
  #-----------------------------------------------------------------------------
  # Command plugin interface
  
  def normalize(reload)
    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

16 entries across 16 versions & 1 rubygems

Version Path
nucleon-0.2.16 lib/core/plugin/command.rb
nucleon-0.2.15 lib/core/plugin/command.rb
nucleon-0.2.14 lib/core/plugin/command.rb
nucleon-0.2.13 lib/core/plugin/command.rb
nucleon-0.2.12 lib/core/plugin/command.rb
nucleon-0.2.11 lib/core/plugin/command.rb
nucleon-0.2.10 lib/core/plugin/command.rb
nucleon-0.2.9 lib/core/plugin/command.rb
nucleon-0.2.8 lib/core/plugin/command.rb
nucleon-0.2.7 lib/core/plugin/command.rb
nucleon-0.2.6 lib/core/plugin/command.rb
nucleon-0.2.5 lib/core/plugin/command.rb
nucleon-0.2.4 lib/core/plugin/command.rb
nucleon-0.2.3 lib/core/plugin/command.rb
nucleon-0.2.2 lib/core/plugin/command.rb
nucleon-0.2.1 lib/core/plugin/command.rb