Guest User

Untitled

a guest
Sep 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "flag"
  5. "io/ioutil"
  6. )
  7.  
  8. type cliFlags struct {
  9. fileIn string
  10. fileOut string
  11. }
  12.  
  13. func main() {
  14. cf := new(cliFlags)
  15.  
  16. flag.StringVar(&cf.fileIn, "in", "openapi.json", "name of the openapi json file")
  17. flag.StringVar(&cf.fileOut, "out", "openapi.md", "name of the output markdown file")
  18. flag.Parse()
  19.  
  20. dataIn, err := ioutil.ReadFile(cf.fileIn)
  21. if err != nil {
  22. panic(err)
  23. }
  24.  
  25. replaceRefs(string(dataIn))
  26.  
  27. oa, err := read(dataIn)
  28. if err != nil {
  29. panic(err)
  30. }
  31.  
  32. md, err := write(oa)
  33. if err != nil {
  34. panic(err)
  35. }
  36.  
  37. err = ioutil.WriteFile(cf.fileOut, []byte(md), 0644)
  38. if err != nil {
  39. panic(err)
  40. }
  41. }
Add Comment
Please, Sign In to add comment