func addACBuildAnnotation(cmd *cobra.Command, args []string) error { const annoNamePattern = "appc.io/acbuild/command-%d" acb := newACBuild() man, err := util.GetManifest(acb.CurrentACIPath) if err != nil { return err } var acbuildCount int for _, ann := range man.Annotations { var tmpCount int n, _ := fmt.Sscanf(string(ann.Name), annoNamePattern, &tmpCount) if n == 1 && tmpCount > acbuildCount { acbuildCount = tmpCount } } command := cmd.Name() tmpcmd := cmd.Parent() for { command = tmpcmd.Name() + " " + command if tmpcmd == cmdAcbuild { break } tmpcmd = tmpcmd.Parent() } for _, a := range args { command += fmt.Sprintf(" %q", a) } return acb.AddAnnotation(fmt.Sprintf(annoNamePattern, acbuildCount+1), command) }