code: func tryWaitForUnitStates(units []string, state string, js job.JobState, maxAttempts int, out io.Writer) error {
  	// We do not wait just assume we reached the desired state
  	if maxAttempts <= -1 {
  		for _, name := range units {
  			stdout("Triggered unit %s %s", name, state)
  		}
  		return nil
  	}
  
  	errchan := waitForUnitStates(units, js, maxAttempts, out)
  	for err := range errchan {
  		stderr("Error waiting for units: %v", err)
  		return err
  	}
  
  	return nil
  }
docs: // tryWaitForUnitStates tries to wait for units to reach the desired state.
  // It takes 5 arguments, the units to wait for, the desired state, the
  // desired JobState, how many attempts before timing out and a writer
  // interface.
  // tryWaitForUnitStates polls each of the indicated units until they
  // reach the desired state. If maxAttempts is negative, then it will not
  // wait, it will assume that all units reached their desired state.
  // If maxAttempts is zero tryWaitForUnitStates will retry forever, and
  // if it is greater than zero, it will retry up to the indicated value.
  // It returns nil on success or error on failure.