code: func NewFromFlags(fl *Flags) (types.Target, error) {
  	if fl.TargetType == "task" {
  		if fl.TaskServiceName == "" {
  			return nil, errors.New(
  				"--ts-mon-task-service-name must be provided when using --ts-mon-target-type=task")
  		}
  		if fl.TaskJobName == "" {
  			return nil, errors.New(
  				"--ts-mon-task-job-name must be provided when using --ts-mon-target-type=task")
  		}
  
  		return &Task{
  			ServiceName: fl.TaskServiceName,
  			JobName:     fl.TaskJobName,
  			DataCenter:  fl.TaskRegion,
  			HostName:    fl.TaskHostname,
  			TaskNum:     int32(fl.TaskNumber),
  		}, nil
  	} else if fl.TargetType == "device" {
  		return &NetworkDevice{
  			Metro:     fl.DeviceRegion,
  			Role:      fl.DeviceRole,
  			Hostname:  fl.DeviceHostname,
  			Hostgroup: fl.DeviceNetwork,
  		}, nil
  	} else {
  		return nil, fmt.Errorf("unknown --ts-mon-target-type '%s'", fl.TargetType)
  	}
  }
docs: // NewFromFlags returns a Target configured from commandline flags.