exe/zup-generator in zup-generator-0.1.0 vs exe/zup-generator in zup-generator-0.1.1
- old
+ new
@@ -1,10 +1,13 @@
#!/usr/bin/env ruby
require "tty-prompt"
require "zup/generator"
+require "zup/swagger"
+@zup = Zup::Generator.new
+@swagger = Zup::Swagger.new
@prompt = TTY::Prompt.new
@header = """
########################################################################
########################################################################
@@ -25,11 +28,10 @@
heart = @prompt.decorate('🍺 ')
user = @prompt.ask('Qual o seu e-mail da zup?', default: ENV['USER'])
pass = @prompt.mask("Qual sua senha?", mask: heart)
- @zup = Zup::Generator.new
if @zup.login(user, pass)
puts "LOGADO"
else
login(true)
end
@@ -79,21 +81,70 @@
"Sair",
])
case selected
when "Copiar para Clipboard o YAML"
- copy_yaml
+ copy_yaml
when "Selecionar outra API"
- choice_api
+ choice_api
+ when "Gerar pacote de Client"
+ export_client
when "Sair"
- sair
+ sair
end
end
def copy_yaml
- @zup.pbcopy JSON.parse(@zup.generate_swagger(@api[:id], @version[:id]).to_json).to_yaml
+ @zup.pbcopy @zup.generate_swagger(@api[:id], @version[:id], "yaml")
+ choice_action
+end
+def export_client
+ system("clear")
+ puts @header
+
+ if @swagger.installed?
+ select_language
+ generate_files
+ else
+ tutorial_install_swagger
+ end
+end
+
+def select_language
+ system("clear")
+ puts @header
+
+ @lang = @prompt.select("Qual a linguágem do client que deseja gerar?", @swagger.languages)
+end
+
+def generate_files
+ system("clear")
+ puts @header
+
+ select_output
+
+ puts "Gerando..."
+
+ content = @zup.generate_swagger(@api[:id], @version[:id])
+ @swagger.generate(content, @lang, @output)
+
choice_action
+end
+
+def select_output
+ system("clear")
+ puts @header
+
+ @output = @prompt.ask('Onde deseja salvar?', default: "output/")
+end
+
+def tutorial_install_swagger
+ puts """
+
+ O swagger-codegen não está instalado em sua maquina.
+
+ """
end
def sair
system("clear")
end
\ No newline at end of file