Sha256: 9cc807f9ba51be33d3c4d2e508af5dfd5d0c578bcf8547db8bdbe18a52ff47d3

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

module GoodData
  module Command
    class Projects < Base
      def list
        connect
        Project.all.each do |project|
          puts "%s  %s" % [project.uri, project.title]
        end
      end
      alias :index :list

      def create
        connect

        title = ask "Project name"
        summary = ask "Project summary"
        template = ask "Project template", :default => ''

        project = Project.create :title => title, :summary => summary, :template => template

        puts "Project '#{project.title}' with id #{project.uri} created successfully!"
      end

      def show
        id = args.shift rescue nil
        raise(CommandFailed, "Specify the project key you wish to show.") if id.nil?
        connect
        pp Project[id].to_json
      end

      def delete
        raise(CommandFailed, "Specify the project key(s) for the project(s) you wish to delete.") if args.size == 0
        connect
        while args.size > 0
          id = args.shift
          project = Project[id]
          ask "Do you want to delete the project '#{project.title}' with id #{project.uri}", :answers => %w(y n) do |answer|
            case answer
            when 'y' then
              puts "Deleting #{project.title}..."
              project.delete
              puts "Project '#{project.title}' with id #{project.uri} deleted successfully!"
            when 'n' then
              puts "Aborting..."
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gooddata-0.5.16 lib/gooddata/commands/projects.rb
gooddata-0.5.15 lib/gooddata/commands/projects.rb
gooddata-0.5.14 lib/gooddata/commands/projects.rb
gooddata-0.5.13 lib/gooddata/commands/projects.rb
gooddata-0.5.12 lib/gooddata/commands/projects.rb
gooddata-0.5.11 lib/gooddata/commands/projects.rb
gooddata-0.5.10 lib/gooddata/commands/projects.rb
gooddata-0.5.9 lib/gooddata/commands/projects.rb
gooddata-0.5.8 lib/gooddata/commands/projects.rb
gooddata-0.5.7 lib/gooddata/commands/projects.rb
gooddata-0.5.6 lib/gooddata/commands/projects.rb