<commit_before>package main

import (
	"fmt"
	"strings"

	"github.com/codegangsta/cli"
)

const packageNotFond = "package not found."

type Commands struct {
	PackagesCache *PackagesCache
	Packages      *Packages
}

func NewCommnads(cachePath string) *Commands {
	pj := NewPackagesCache(cachePath)
	pj.FetchIfNeeded()
	c := &Commands{pj, NewPackages(pj.PackagesCachePath)}
	return c
}

func (c *Commands) List(cli *cli.Context) {
	showDesc := cli.Bool("d")
	isPlist := cli.Bool("p")

	if cli.Bool("u") {
		c.Update()
	}

	ps := c.Packages
	if isPlist {
		fmt.Printf("(gocdnjs-version \"%s\" name-max-length %d packages (",
			AppVersion, ps.Len.NameMax)
		for _, p := range *ps.Packages {
			fmt.Printf("(name \"%s\" version \"%s\" ", p.Name, p.Version)
			if showDesc {
				fmt.Printf("description \"%s\"", TrimNewLine(p.Description))
			}
			fmt.Print(")")
		}
		fmt.Print("))")
	} else {
		for _, p := range *ps.Packages {
			fmt.Printf("%s%s (%s)",
				p.Name, strings.Repeat(" ", ps.Len.NameMax-len(p.Name)),
				p.Version)
			if showDesc {
				fmt.Printf(" %s", TrimNewLine(p.Description))
			}
			fmt.Println()
		}
	}
}

func (c *Commands) Search(str string) {
	ps := c.Packages
	ps = ps.Search(str)
	for _, p := range *ps.Packages {
		fmt.Printf("%s%s (%s)%s\n",
			p.Name, strings.Repeat(" ", ps.Len.NameMax-len(p.Name)),
			p.Version, strings.Repeat(" ", ps.Len.VersionMax-len(p.Version)))
	}
}

func (c *Commands) Info(cli *cli.Context) {
	name := cli.Args().First()
	isPlist := cli.Bool("p")

	if cli.Bool("u") {
		c.Update()
	}

	p := c.Packages.SearchWithName(name)
	if p == nil {
		fmt.Println(packageNotFond)
	} else {
		fmt.Println(infoString(p, isPlist))
	}
}

func (c *Commands) Url(cli *cli.Context) {
	name := cli.Args().First()

	if cli.Bool("u") {
		c.Update()
	}

	p := c.Packages.SearchWithName(name)
	if p == nil {
		fmt.Println(packageNotFond)
	} else {
		version := p.Version
		if v := cli.Args().Get(1); v != "" {
			version = v
		}
		link := GenereateLink(p.Name, version, p.FileName)
		fmt.Println(link)
	}
}

func (c *Commands) Update() {
	pj := c.PackagesCache
	pj.Purge()
	pj.Fetch()
}

func (c *Commands) Download(cli *cli.Context) {
	name := cli.Args().First()

	if p := c.Packages.SearchWithName(name); p == nil {
		fmt.Println(packageNotFond)
	} else {
		p.Download(cli.String("d"), cli.String("v"))
	}
}

func (c *Commands) CahcePath() {
	pj := c.PackagesCache
	fmt.Println(pj.PackagesCachePath)
}

func infoString(p *Package, isPlist bool) string {
	assets := (p.Assets)

	str := ""
	if isPlist {
		str += fmt.Sprintf("(package \"%s\" version \"%s\" ", p.Name, assets[0].Version)
		if p.Homepage != "" {
			str += fmt.Sprintf("homepage \"%s\" ", p.Homepage)
		}
		str += fmt.Sprintf("description \"%s\" ", p.Description)

		str += fmt.Sprint("assets (")
		for _, a := range assets {
			str += fmt.Sprintf("(\"%s\" (", a.Version)
			for _, f := range a.Files {
				link := GenereateLink(p.Name, a.Version, f)
				str += fmt.Sprintf("\"%s\" ", link)
			}
			str += fmt.Sprint("))")
		}
		str += fmt.Sprint("))")
	} else {
		str += fmt.Sprintf("%s\n\n", p.Name)
		if p.Homepage != "" {
			str += fmt.Sprintf("HOMEPAGE:\n   %s\n\n", p.Homepage)
		}
		str += fmt.Sprintf("DESCRIPTION:\n   %s\n\n", p.Description)
		str += fmt.Sprintln("ASSETS:")
		for _, a := range assets {
			for _, f := range a.Files {
				link := GenereateLink(p.Name, a.Version, f)
				str += fmt.Sprintf("   %s\n", link)
			}
			str += fmt.Sprintln()
		}
	}

	return str
}
<commit_msg>escape " for description string<commit_after>package main

import (
	"fmt"
	"strings"

	"github.com/codegangsta/cli"
)

const packageNotFond = "package not found."

type Commands struct {
	PackagesCache *PackagesCache
	Packages      *Packages
}

func NewCommnads(cachePath string) *Commands {
	pj := NewPackagesCache(cachePath)
	pj.FetchIfNeeded()
	c := &Commands{pj, NewPackages(pj.PackagesCachePath)}
	return c
}

func (c *Commands) List(cli *cli.Context) {
	showDesc := cli.Bool("d")
	isPlist := cli.Bool("p")

	if cli.Bool("u") {
		c.Update()
	}

	ps := c.Packages
	if isPlist {
		fmt.Printf("(gocdnjs-version \"%s\" name-max-length %d packages (",
			AppVersion, ps.Len.NameMax)
		for _, p := range *ps.Packages {
			fmt.Printf("(name \"%s\" version \"%s\" ", p.Name, p.Version)
			if showDesc {
				str := strings.Replace(p.Description, "'", "\\'", -1)
				str = strings.Replace(str, "\"", "\\\"", -1)
				fmt.Printf("description \"%s\"", TrimNewLine(str))
			}
			fmt.Print(")")
		}
		fmt.Print("))")
	} else {
		for _, p := range *ps.Packages {
			fmt.Printf("%s%s (%s)",
				p.Name, strings.Repeat(" ", ps.Len.NameMax-len(p.Name)),
				p.Version)
			if showDesc {
				fmt.Printf(" %s", TrimNewLine(p.Description))
			}
			fmt.Println()
		}
	}
}

func (c *Commands) Search(str string) {
	ps := c.Packages
	ps = ps.Search(str)
	for _, p := range *ps.Packages {
		fmt.Printf("%s%s (%s)%s\n",
			p.Name, strings.Repeat(" ", ps.Len.NameMax-len(p.Name)),
			p.Version, strings.Repeat(" ", ps.Len.VersionMax-len(p.Version)))
	}
}

func (c *Commands) Info(cli *cli.Context) {
	name := cli.Args().First()
	isPlist := cli.Bool("p")

	if cli.Bool("u") {
		c.Update()
	}

	p := c.Packages.SearchWithName(name)
	if p == nil {
		fmt.Println(packageNotFond)
	} else {
		fmt.Println(infoString(p, isPlist))
	}
}

func (c *Commands) Url(cli *cli.Context) {
	name := cli.Args().First()

	if cli.Bool("u") {
		c.Update()
	}

	p := c.Packages.SearchWithName(name)
	if p == nil {
		fmt.Println(packageNotFond)
	} else {
		version := p.Version
		if v := cli.Args().Get(1); v != "" {
			version = v
		}
		link := GenereateLink(p.Name, version, p.FileName)
		fmt.Println(link)
	}
}

func (c *Commands) Update() {
	pj := c.PackagesCache
	pj.Purge()
	pj.Fetch()
}

func (c *Commands) Download(cli *cli.Context) {
	name := cli.Args().First()

	if p := c.Packages.SearchWithName(name); p == nil {
		fmt.Println(packageNotFond)
	} else {
		p.Download(cli.String("d"), cli.String("v"))
	}
}

func (c *Commands) CahcePath() {
	pj := c.PackagesCache
	fmt.Println(pj.PackagesCachePath)
}

func infoString(p *Package, isPlist bool) string {
	assets := (p.Assets)

	str := ""
	if isPlist {
		str += fmt.Sprintf("(package \"%s\" version \"%s\" ", p.Name, assets[0].Version)
		if p.Homepage != "" {
			str += fmt.Sprintf("homepage \"%s\" ", p.Homepage)
		}
		str += fmt.Sprintf("description \"%s\" ", p.Description)

		str += fmt.Sprint("assets (")
		for _, a := range assets {
			str += fmt.Sprintf("(\"%s\" (", a.Version)
			for _, f := range a.Files {
				link := GenereateLink(p.Name, a.Version, f)
				str += fmt.Sprintf("\"%s\" ", link)
			}
			str += fmt.Sprint("))")
		}
		str += fmt.Sprint("))")
	} else {
		str += fmt.Sprintf("%s\n\n", p.Name)
		if p.Homepage != "" {
			str += fmt.Sprintf("HOMEPAGE:\n   %s\n\n", p.Homepage)
		}
		str += fmt.Sprintf("DESCRIPTION:\n   %s\n\n", p.Description)
		str += fmt.Sprintln("ASSETS:")
		for _, a := range assets {
			for _, f := range a.Files {
				link := GenereateLink(p.Name, a.Version, f)
				str += fmt.Sprintf("   %s\n", link)
			}
			str += fmt.Sprintln()
		}
	}

	return str
}

{'fraction_non_alphanumeric': 0.2067314462751725, 'fraction_numerical': 0.0008449514152936206, 'mean_word_length': 3.1998817267888824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6735565', 'n_tokens_mistral': 3119, 'n_tokens_neox': 2911, 'n_words': 565}