Exemplo n.º 1
0
func (tc *targetFromArgs) GetTargets(c *cli.Context) ([]*config.Target, error) {
	var targets []*config.Target

	timeout := config.GetTimeDurationConfig(c, "timeout")
	for _, entry := range c.Args() {
		t, err := config.ParseTarget(entry)
		if err != nil {
			return nil, err
		}
		t.Timeout = timeout
		targets = append(targets, t)
	}
	return targets, nil
}
Exemplo n.º 2
0
func (tc *targetFromFile) GetTargets(c *cli.Context) ([]*config.Target, error) {
	filename := c.String("file")
	if filename == "" {
		return []*config.Target{}, nil
	}

	timeout := config.GetTimeDurationConfig(c, "timeout")
	turnOffEnvExpansion := c.Bool("no-environment")

	file, err := os.Open(filename)
	if err != nil {
		return nil, err
	}

	return tc.targetsFromReaderWithTimeout(file, timeout, turnOffEnvExpansion)
}