Exemplo n.º 1
0
// readConfig reads config provided as cmd-line args,
// and merges it with the defaults
func (c *EngageCommand) readQueryOptions(config *api.Config) (*api.QueryOptions, error) {
	cmdFlags := flag.NewFlagSet("engage", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }

	var cmdQueryOptions api.QueryOptions
	var out string
	cmdFlags.StringVar(&out, "out", "", "output destination")
	if err := cmdFlags.Parse(c.args); err != nil {
		return nil, err
	}
	if out != "" {
		c.out = out
	}

	queryOptions := api.DefaultQueryOptions(config)
	// Not all config would be provided as cmd-line args
	queryOptions = api.MergeQueryOptions(queryOptions, &cmdQueryOptions)
	return queryOptions, nil
}
Exemplo n.º 2
0
// readConfig reads config provided as cmd-line args,
// and merges it with the defaults
func (c *ExportCommand) readQueryOptions(config *api.Config) (*api.QueryOptions, error) {
	cmdFlags := flag.NewFlagSet("export", flag.ContinueOnError)
	cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }

	var cmdQueryOptions api.QueryOptions
	var out string
	cmdFlags.StringVar(&cmdQueryOptions.FromDate, "from", "", "from date")
	cmdFlags.StringVar(&cmdQueryOptions.ToDate, "to", "", "to date")
	cmdFlags.StringVar(&cmdQueryOptions.Format, "format", "", "data format")
	cmdFlags.StringVar(&cmdQueryOptions.Event, "event", "", "event name")
	cmdFlags.StringVar(&out, "out", "", "output destination")
	if err := cmdFlags.Parse(c.args); err != nil {
		return nil, err
	}
	if out != "" {
		c.out = out
	}

	queryOptions := api.DefaultExportQueryOptions(config)
	// Not all config would be provided as cmd-line args
	queryOptions = api.MergeQueryOptions(queryOptions, &cmdQueryOptions)
	return queryOptions, nil
}