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