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