You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
946 B

  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. amber "github.com/eknkc/amber"
  6. "os"
  7. )
  8. var prettyPrint bool
  9. var lineNumbers bool
  10. func init() {
  11. flag.BoolVar(&prettyPrint, "prettyprint", true, "Use pretty indentation in output html.")
  12. flag.BoolVar(&prettyPrint, "pp", true, "Use pretty indentation in output html.")
  13. flag.BoolVar(&lineNumbers, "linenos", true, "Enable debugging information in output html.")
  14. flag.BoolVar(&lineNumbers, "ln", true, "Enable debugging information in output html.")
  15. flag.Parse()
  16. }
  17. func main() {
  18. input := flag.Arg(0)
  19. if len(input) == 0 {
  20. fmt.Fprintln(os.Stderr, "Please provide an input file. (amberc input.amber)")
  21. os.Exit(1)
  22. }
  23. cmp := amber.New()
  24. cmp.PrettyPrint = prettyPrint
  25. cmp.LineNumbers = lineNumbers
  26. err := cmp.ParseFile(input)
  27. if err != nil {
  28. fmt.Fprintln(os.Stderr, err)
  29. os.Exit(1)
  30. }
  31. err = cmp.CompileWriter(os.Stdout)
  32. if err != nil {
  33. fmt.Fprintln(os.Stderr, err)
  34. os.Exit(1)
  35. }
  36. }