Sha256: 90966a41784c628a8c66623ca2dd134872515b7c62f6e835efe12b32fe31f051

Contents?: true

Size: 1.98 KB

Versions: 5

Compression:

Stored size: 1.98 KB

Contents

require "thor"
require "colorize"
require "qiita_org/version"
require "qiita_org/post"
require "qiita_org/config"
require "qiita_org/get"
require "qiita_org/list"
require "qiita_org/get_template"
#require "qiita_org/qiita_org_thor"

module QiitaOrg
  class CLI < Thor
    #    def initialize(*argv)
    #      super(*argv)
    #    end
    #
    desc "say_hello", "say_hello"

    def say_hello(*name)
      name = name[0] || "world"
      puts "Hello #{name}."
    end

    desc "post", "post to qiita from org"

    def post(*argv)
      p ["in qiita_org.rb", argv]
      p file = argv[0] || "README.org"
      p mode = argv[1] || "private"
      qiita = QiitaPost.new(file, mode)
      begin
        qiita.select_option(mode)
      rescue RuntimeError => e
        puts $!
      else
        qiita.run
      end
    end

    desc "config", "set config"

    def config(*argv)
      status = argv[0] || "local"
      option = argv[1] || nil
      input = [argv[2], argv[3], argv[4]]
      config =  QiitaConfig.new(status, option, input)
      config.run
    end

    desc "get", "get qiita report"

    def get(*argv)
      p mode = argv[0] || "qiita"
      p id = argv[1] || nil
      get =  QiitaGet.new(mode, id)
      get.run
    end

    desc "template", "make template.org"

    def template(*argv)
      template = QiitaGetTemplate.new()
    end

    desc "all", "post all org file in the directory"

    def all(*argv)
      Dir.glob("*.org").each do |org|
        puts org.blue
        if File.read(org).match(/#\+qiita_(.+)/)
          system ("qiita post #{org} open") if File.read(org).match(/#\+(.+)_public/)
          system ("qiita post #{org} teams") if File.read(org).match(/#\+(.+)_teams/)
          system ("qiita post #{org} private") if File.read(org).match(/#\+(.+)_private/)
        else
          system ("qiita post #{org}")
        end
      end
    end

    desc "list", "view qiita report list"

    def list(*argv)
      p mode = argv[0] || "qiita"
      QiitaList.new(mode)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qiita_org-0.1.9 lib/qiita_org.rb
qiita_org-0.1.8 lib/qiita_org.rb
qiita_org-0.1.7 lib/qiita_org.rb
qiita_org-0.1.6 lib/qiita_org.rb
qiita_org-0.1.5 lib/qiita_org.rb