ecal.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * ECAL
  3. *
  4. * Copyright 2020 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the MIT
  7. * License, If a copy of the MIT License was not distributed with this
  8. * file, You can obtain one at https://opensource.org/licenses/MIT.
  9. */
  10. package main
  11. import (
  12. "flag"
  13. "fmt"
  14. "os"
  15. "devt.de/krotik/ecal/config"
  16. )
  17. /*
  18. TODO:
  19. - CLI interpreter (show base directory when starting)
  20. -- console can specify a base directory
  21. -- console can preload code
  22. - create executable binary (pack into single binary)
  23. - debug server support (vscode)
  24. */
  25. func main() {
  26. // Initialize the default command line parser
  27. flag.CommandLine.Init(os.Args[0], flag.ContinueOnError)
  28. // Define default usage message
  29. flag.Usage = func() {
  30. // Print usage for tool selection
  31. fmt.Println(fmt.Sprintf("Usage of %s <tool>", os.Args[0]))
  32. fmt.Println()
  33. fmt.Println(fmt.Sprintf("ECAL %v - Event Condition Action Language", config.ProductVersion))
  34. fmt.Println()
  35. fmt.Println("Available commands:")
  36. fmt.Println()
  37. fmt.Println(" console Interactive console (default)")
  38. fmt.Println(" run Execute ECAL code")
  39. fmt.Println(" debug Run a debug server")
  40. fmt.Println(" pack Create a single executable from ECAL code")
  41. fmt.Println()
  42. fmt.Println(fmt.Sprintf("Use %s <command> -help for more information about a given command.", os.Args[0]))
  43. fmt.Println()
  44. }
  45. // Parse the command bit
  46. err := flag.CommandLine.Parse(os.Args[1:])
  47. if len(flag.Args()) > 0 {
  48. arg := flag.Args()[0]
  49. if arg == "console" {
  50. } else {
  51. flag.Usage()
  52. }
  53. } else if err == nil {
  54. // TODO: console
  55. }
  56. }