main.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package main
  2. import (
  3. "encoding/json"
  4. "mimicry/kinds"
  5. "os"
  6. "fmt"
  7. // "mimicry/style"
  8. // "mimicry/render"
  9. )
  10. // TODO: even if only supported in few terminals,
  11. // consider using the proportional spacing codes when possible
  12. // TODO: when returning errors, use zero value for return
  13. // also change all error messages to using sprintf-style
  14. // formatting, all lowercase, and no punctuation
  15. func main() {
  16. // fmt.Println(style.Bold("Bold") + "\tNot Bold")
  17. // fmt.Println(style.Strikethrough("Strikethrough") + "\tNot Strikethrough")
  18. // fmt.Println(style.Underline("Underline") + "\tNot Underline")
  19. // fmt.Println(style.Italic("Italic") + "\tNot Italic")
  20. // fmt.Println(style.Code("Code") + "\tNot Code")
  21. // fmt.Println(style.Highlight("Highlight") + "\tNot Highlight")
  22. // fmt.Println(style.Highlight("Stuff here " + style.Code("CODE") + " more here"))
  23. // fmt.Println(style.Bold("struff " + style.Strikethrough("bad") + " more stuff"))
  24. // fmt.Println(style.Linkify("Hello!"))
  25. // output, err := render.Render("<p>Hello<code>hi</code> Everyone</p><i>@everyone</i> <blockquote>please<br>don't!</blockquote>", "text/html")
  26. // if err != nil {
  27. // panic(err)
  28. // }
  29. // fmt.Println(output)
  30. link := os.Args[len(os.Args)-1]
  31. command := os.Args[1]
  32. content, err := kinds.FetchUnknown(link)
  33. if err != nil {
  34. panic(err)
  35. }
  36. if command == "raw" {
  37. enc := json.NewEncoder(os.Stdout)
  38. if err := enc.Encode(content); err != nil {
  39. panic(err)
  40. }
  41. return
  42. }
  43. if str, err := content.String(); err != nil {
  44. panic(err)
  45. } else {
  46. fmt.Println(str)
  47. }
  48. }