options.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package core
  2. import (
  3. "flag"
  4. )
  5. type Options struct {
  6. InterfaceName *string
  7. Gateway *string
  8. Caplet *string
  9. AutoStart *string
  10. Debug *bool
  11. Silent *bool
  12. NoColors *bool
  13. NoHistory *bool
  14. PrintVersion *bool
  15. EnvFile *string
  16. Commands *string
  17. CpuProfile *string
  18. MemProfile *string
  19. CapletsPath *string
  20. Script *string
  21. PcapBufSize *int
  22. }
  23. func ParseOptions() (Options, error) {
  24. o := Options{
  25. InterfaceName: flag.String("iface", "", "Network interface to bind to, if empty the default interface will be auto selected."),
  26. Gateway: flag.String("gateway-override", "", "Use the provided IP address instead of the default gateway. If not specified or invalid, the default gateway will be used."),
  27. AutoStart: flag.String("autostart", "events.stream", "Comma separated list of modules to auto start."),
  28. Caplet: flag.String("caplet", "", "Read commands from this file and execute them in the interactive session."),
  29. Debug: flag.Bool("debug", false, "Print debug messages."),
  30. PrintVersion: flag.Bool("version", false, "Print the version and exit."),
  31. Silent: flag.Bool("silent", false, "Suppress all logs which are not errors."),
  32. NoColors: flag.Bool("no-colors", false, "Disable output color effects."),
  33. NoHistory: flag.Bool("no-history", false, "Disable interactive session history file."),
  34. EnvFile: flag.String("env-file", "", "Load environment variables from this file if found, set to empty to disable environment persistence."),
  35. Commands: flag.String("eval", "", "Run one or more commands separated by ; in the interactive session, used to set variables via command line."),
  36. CpuProfile: flag.String("cpu-profile", "", "Write cpu profile `file`."),
  37. MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."),
  38. CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."),
  39. Script: flag.String("script", "", "Load a session script."),
  40. PcapBufSize: flag.Int("pcap-buf-size", -1, "PCAP buffer size, leave to 0 for the default value."),
  41. }
  42. flag.Parse()
  43. return o, nil
  44. }