package graph

import (
	"github.com/docker/docker/engine"
)

func (s *TagStore) CmdTag(job *engine.Job) engine.Status {
	if len(job.Args) != 2 && len(job.Args) != 3 {
		return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name)
	}
	var tag string
	if len(job.Args) == 3 {
		tag = job.Args[2]
	}
	if err := s.Set(job.Args[1], tag, job.Args[0], job.GetenvBool("force"), false); err != nil {
		return job.Error(err)
	}
	return engine.StatusOK
}
