main.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //go:generate goversioninfo -icon=windowsdata/resource/netclient.ico -manifest=netclient.exe.manifest.xml -64=true -o=netclient.syso
  2. // -build gui
  3. package main
  4. import (
  5. "log"
  6. "os"
  7. "runtime/debug"
  8. "github.com/gravitl/netmaker/netclient/cli_options"
  9. "github.com/gravitl/netmaker/netclient/config"
  10. "github.com/gravitl/netmaker/netclient/ncutils"
  11. "github.com/urfave/cli/v2"
  12. )
  13. var version = "dev"
  14. func main() {
  15. app := cli.NewApp()
  16. app.Name = "Netclient"
  17. app.Version = version
  18. ncutils.SetVersion(version)
  19. cliFlags := cli_options.GetFlags(ncutils.GetHostname())
  20. app.Commands = cli_options.GetCommands(cliFlags[:])
  21. app.Description = "Used to perform interactions with Netmaker server and set local WireGuard config."
  22. app.Usage = "Netmaker's netclient agent and CLI."
  23. app.UsageText = "netclient [global options] command [command options] [arguments...]. Adjust verbosity of given command with -v, -vv or -vvv (max)."
  24. setGarbageCollection()
  25. if !ncutils.IsWindows() {
  26. ncutils.CheckUID()
  27. ncutils.CheckWG()
  28. }
  29. if len(os.Args) <= 1 && config.GuiActive {
  30. config.GuiRun.(func())()
  31. } else {
  32. err := app.Run(os.Args)
  33. if err != nil {
  34. log.Fatal(err)
  35. }
  36. }
  37. }
  38. func setGarbageCollection() {
  39. _, gcset := os.LookupEnv("GOGC")
  40. if !gcset {
  41. debug.SetGCPercent(ncutils.DEFAULT_GC_PERCENT)
  42. }
  43. }