code: def save_task(self, task):
          
  
          args = [task['uuid'], 'modify'] if task.saved else ['add']
          args.extend(self._get_modified_task_fields_as_args(task))
          output = self.execute_command(args)
  
          # Parse out the new ID, if the task is being added for the first time
          if not task.saved:
              id_lines = [l for l in output if l.startswith('Created task ')]
  
              # Complain loudly if it seems that more tasks were created
              # Should not happen.
              # Expected output: Created task 1.
              #                  Created task 1 (recurrence template).
              if len(id_lines) != 1 or len(id_lines[0].split(' ')) not in (3, 5):
                  raise TaskWarriorException(
                      'Unexpected output when creating '
                      'task: %s' % '\n'.join(id_lines),
                  )
  
              # Circumvent the ID storage, since ID is considered read-only
              identifier = id_lines[0].split(' ')[2].rstrip('.')
  
              # Identifier can be either ID or UUID for completed tasks
              try:
                  task._data['id'] = int(identifier)
              except ValueError:
                  task._data['uuid'] = identifier
  
          # Refreshing is very important here, as not only modification time
          # is updated, but arbitrary attribute may have changed due hooks
          # altering the data before saving
          task.refresh(after_save=True)
docs: Save a task into TaskWarrior database using add/modify call