Class: QiitaOrg::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/qiita_org.rb

Instance Method Summary collapse

Constructor Details

#initialize(*argv) ⇒ CLI

def initialize(*argv)

  super(*argv)
end


24
25
26
# File 'lib/qiita_org.rb', line 24

def initialize(*argv)
  super(*argv)
end

Instance Method Details

#all(*argv) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/qiita_org.rb', line 112

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

#config(*argv) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/qiita_org.rb', line 84

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

#get(*argv) ⇒ Object



94
95
96
97
98
99
# File 'lib/qiita_org.rb', line 94

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

#list(*argv) ⇒ Object



127
128
129
130
# File 'lib/qiita_org.rb', line 127

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

#post(*argv) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/qiita_org.rb', line 37

def post(*argv)
  checkos = CheckPcOs.new
  os = checkos.return_os()

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

#say_hello(*name) ⇒ Object



30
31
32
33
# File 'lib/qiita_org.rb', line 30

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

#template(*argv) ⇒ Object



103
104
105
106
107
108
# File 'lib/qiita_org.rb', line 103

def template(*argv)
  checkos = CheckPcOs.new
  os = checkos.return_os()

  template = QiitaGetTemplate.new(os).run()
end

#upload(*argv) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/qiita_org.rb', line 56

def upload(*argv)
  checkos = CheckPcOs.new
  os = checkos.return_os()

  p file = argv[0] || "README.org"
  p mode = argv[1] || DecideOption.new(file).decide_option()

  UpLoad.new(file, mode, os).upload()
=begin
  getpath = GetFilePath.new(file)
  paths = getpath.get_file_path()
  unless paths.empty?
    showfile = ShowFile.new(paths, file, mode, os)
    showfile.open_file_dir()
    showfile.open_qiita()

    puts "Input file URL's on #{file}? (y/n)".green
    ans = STDIN.getch

    if ans == "y"
      showfile.input_url_to_org()
    end
  end
=end
end

#versionObject



134
135
136
# File 'lib/qiita_org.rb', line 134

def version
  puts QiitaOrg::VERSION
end