Class: QiitaOrg::CLI
- Inherits:
-
Thor
- Object
- Thor
- QiitaOrg::CLI
- Defined in:
- lib/qiita_org.rb
Instance Method Summary collapse
- #all(*argv) ⇒ Object
- #config(*argv) ⇒ Object
- #get(*argv) ⇒ Object
-
#initialize(*argv) ⇒ CLI
constructor
A new instance of CLI.
- #list(*argv) ⇒ Object
- #post(*argv) ⇒ Object
- #say_hello(*name) ⇒ Object
- #template(*argv) ⇒ Object
- #upload(*argv) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*argv) ⇒ CLI
Returns a new instance of CLI.
18 19 20 21 |
# File 'lib/qiita_org.rb', line 18 def initialize(*argv) super(*argv) @base = QiitaBase.new() end |
Instance Method Details
#all(*argv) ⇒ Object
106 107 108 |
# File 'lib/qiita_org.rb', line 106 def all(*argv) QiitaAll.new(argv).run() end |
#config(*argv) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/qiita_org.rb', line 77 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
87 88 89 90 91 92 |
# File 'lib/qiita_org.rb', line 87 def get(*argv) p mode = argv[0] || "qiita" p id = argv[1] || nil get = QiitaGet.new(mode, id) get.run end |
#list(*argv) ⇒ Object
112 113 114 115 |
# File 'lib/qiita_org.rb', line 112 def list(*argv) p mode = argv[0] || "qiita" QiitaList.new(mode) end |
#post(*argv) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/qiita_org.rb', line 32 def post(*argv) os = @base.check_pc_os() if argv.size > 2 GetMultipleFiles.new(argv, os, "post").run() else #if argv.size > 1 if argv[-1].match(/(.+).org/) GetMultipleFiles.new(argv, os, "post").run() else p ["in qiita_org.rb", argv] p file = argv[0] || "README.org" p mode = argv[1] || @base.pick_up_option(file) qiita = QiitaPost.new(file, mode, os) begin qiita.select_option(mode) rescue RuntimeError => e puts $! else qiita.run end end end end |
#say_hello(*name) ⇒ Object
25 26 27 28 |
# File 'lib/qiita_org.rb', line 25 def say_hello(*name) name = name[0] || "world" puts "Hello #{name}." end |
#template(*argv) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/qiita_org.rb', line 96 def template(*argv) os = @base.check_pc_os() filename = argv[0] || "template.org" filename = (filename.include?(".org"))? filename : "#{filename}.org" template = QiitaGetTemplate.new(os, filename).run() end |
#upload(*argv) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/qiita_org.rb', line 58 def upload(*argv) os = @base.check_pc_os() if argv.size > 2 GetMultipleFiles.new(argv, os, "upload").run() else #if argv.size > 1 if argv[-1].match(/(.+).org/) GetMultipleFiles.new(argv, os, "upload").run() else p file = argv[0] || "README.org" p mode = argv[1] || @base.pick_up_option(file) qiita = QiitaFileUpLoad.new(file, mode, os).upload() end end end |
#version ⇒ Object
119 120 121 |
# File 'lib/qiita_org.rb', line 119 def version puts QiitaOrg::VERSION end |