forked from editor-bootstrap/vim-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vim-bootstrap.go
40 lines (34 loc) · 966 Bytes
/
vim-bootstrap.go
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
package main
import (
"flag"
"fmt"
"net/http"
"strings"
"github.com/avelino/vim-bootstrap/generate"
"github.com/avelino/vim-bootstrap/web"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
)
func main() {
langs := flag.String("langs", "", "Set languages used: go,python,c")
editor := flag.String("editor", "vim", "Set editor: vim or nvim")
server := flag.Bool("server", false, "Up http server")
flag.Parse()
if *server {
n := negroni.Classic()
r := mux.NewRouter()
r.HandleFunc("/", web.HandleHome).Methods("GET")
r.HandleFunc("/generate.vim", web.HandleGenerate).Methods("POST")
r.HandleFunc("/hook", web.HandleHook).Methods("POST")
r.PathPrefix("/assets").Handler(
http.StripPrefix("/assets", http.FileServer(http.Dir("./template/assets/"))))
n.UseHandler(r)
n.Run(":3000")
}
obj := generate.Object{
Language: strings.Split(*langs, ","),
Editor: *editor,
}
gen := generate.Generate(&obj)
fmt.Println(gen)
}