main.go 586 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "git.linuxit.ro/turos.robert/mynotes/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 %s nu este configurata\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. }