main.go 585 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "git.linuxit.ro/turos.robert/Site-Cnapsys/lib/server"
  6. )
  7. func main() {
  8. args := os.Args
  9. switch len(args) {
  10. case 3:
  11. if args[1] == "--run" {
  12. serve(args[2])
  13. os.Exit(0)
  14. }
  15. fmt.Printf("Comanda nerecunoscuta: %s\n", args[1])
  16. default:
  17. fmt.Println("Aplicatia necesita minim 2 parametri")
  18. }
  19. fmt.Printf("Argumente rulare: %v\n", args)
  20. }
  21. func serve(filename string) {
  22. srv := server.NewServer(filename)
  23. checkError(srv.Err)
  24. srv.Run()
  25. }
  26. func checkError(err error) {
  27. if err != nil {
  28. fmt.Printf("Eroare %+v\n", err)
  29. os.Exit(0)
  30. }
  31. }