Sha256: fd1c7b52c02dcb9b7d4857a9ce9b35fa95650e6ed6d425676948b7cc327ca062

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module Relish
  module Command
    class Projects < Base

      desc    'list your projects'
      command :default do
        puts format(resource['projects'].get(:accept => :json))
      end
      
      usage   'projects:add <org_or_user_handle>/<project_handle>'
      desc    ['add a project',
               'append :private to make the project private',
               'example: relish projects:add rspec/rspec-core:private']
      command :add do
        puts resource['projects'].post(:handle => handle, :private => private?)
      end
      
      usage   'projects:remove <project_handle>'
      desc    'remove a project'
      command :remove do
        puts resource["projects/#{@param}"].delete
      end
      
    private
      def format(response)
        json_parse(response) do |hash| 
          result = hash['project']['full_handle']
          result << " (private)" if hash['project']['private']
          result
        end
      end
      
      def handle
        @param.without_option
      end
      
      def private?
        @param.extract_option == 'private'
      end
            
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relish-0.1.2 lib/relish/commands/projects.rb