Sha256: a1df65beec10f5f6f53758aaf85306e74d30baddd6934e34e4338974ff70a313

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'readline'
require 'launchy'

module Lingohub::Command
  class Project < Base
    def login
      Lingohub::Command.run_internal "auth:reauthorize", args.dup
    end

    def logout
      Lingohub::Command.run_internal "auth:delete_credentials", args.dup
      display "Local credentials cleared."
    end

    def list
      list = lingohub.projects.all
      if list.size > 0
        display "Projects:\n"
        list.each_pair { |name, project|
          inactive_str = project.inactive? ? '(inactive)' : ''
          display "- #{name} #{inactive_str}"
        }
      else
        display "You have no projects."
      end
    end

    def create
      title = args.shift.strip rescue nil
      lingohub.projects.create title
      display("Created #{title}")
    end

    def rename
      oldtitle = args[0].strip rescue raise(CommandFailed, "Invalid old project name")
      newtitle = args[1].strip rescue raise(CommandFailed, "Invalid new project name")

      project(oldtitle).update(:title => newtitle)
      display("Project renamed from #{oldtitle} to #{newtitle}")
    end

    def info
      display "=== #{project.title}"
      display "Web URL:        #{project.weburl}"
      display "Owner:          #{project.owner}"
      display "Opensource:     #{project.opensource}"
      display "Locales:        #{project.project_locales}"
      display "Description:    #{project.description}"
    end

    def open
      Launchy.open project.weburl
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lingohub-0.3.1 lib/lingohub/commands/project.rb