<commit_before>package repository

import (
	"encoding/json"
	"fmt"
	"os"

	"github.com/runabove/sail/internal"

	"github.com/spf13/cobra"
)

var cmdRepositoryAdd = &cobra.Command{
	// FIXME: only support adding from source via CLI, type external. Rename to 'register' ?
	Use:   "add",
	Short: "Add an external repository: sail repository add [<applicationName>/]<repositoryName> [<registryURL>] [<namespace>/]<externalRepositoryName> ",
	Long: `Add an external repository: sail repository add [<applicationName>/]<repositoryName> [<registryURL>] [<user>/]<externalRepositoryName>[:<tag>]
examples:
	- sail repository add myapp/myrepo docker.private.registry.com privateRegistryAccount/mysql:5.5
	- sail repository add myapp/myrepo dockerHubAccount/mysql:5.5
	- sail repository add myapp/myrepo mysql

[<user>] The account which hold the distant repository. If ommitted it use official docker image.
<externalRepositoryName> the name of the distant repository. Example : tutum/nginx
[<registryURL>] Url of the registry. Default value : the docker hub (e.g. https://hub.docker.com)
Only pubic repositories are supported yet. ADD NOTE FOR PRIVATE REGISTRIES
	`,
	Run: func(cmd *cobra.Command, args []string) {
		var registryURL, externalRepositoryName, repositoryName string
		switch len(args) {
		case 2:
			repositoryName = args[0]
			registryURL = ""
			externalRepositoryName = args[1]
		case 3:
			repositoryName = args[0]
			registryURL = args[1]
			externalRepositoryName = args[2]

		default:
			fmt.Fprintln(os.Stderr, "Invalid usage. sail repository add [<applicationName>/]<repositoryName> [<registryURL>/][<user>/]<externalRepositoryName>[:<tag>]. Please see sail repository add --help")
			return
		}

		n := repositoryAddStruct{
			RegistryURL:            registryURL,
			ExternalRepositoryName: externalRepositoryName,
		}
		repositoryAdd(repositoryName, n)
	},
}<commit_msg>improve doc<commit_after>package repository

import (
	"encoding/json"
	"fmt"
	"os"

	"github.com/runabove/sail/internal"

	"github.com/spf13/cobra"
)

var cmdRepositoryAdd = &cobra.Command{
	// FIXME: only support adding from source via CLI, type external. Rename to 'register' ?
	Use:   "add",
	Short: "Add an external repository: sail repository add [<applicationName>/]<repositoryName> [<registryURL>] [<namespace>/]<externalRepositoryName> ",
	Long: `Add an external repository: sail repository add [<applicationName>/]<repositoryName> [<registryURL>] [<user>/]<externalRepositoryName>[:<tag>]
examples:
	- sail repository add myapp/myrepo docker.private.registry.com privateRegistryAccount/mysql:5.5
	- sail repository add myapp/myrepo dockerHubAccount/mysql:5.5
	- sail repository add myapp/myrepo mysql

[<user>] The account which hold the distant repository. If ommitted it use official docker image.
<externalRepositoryName> the name of the distant repository. Example : tutum/nginx
[<registryURL>] Url of the registry. Default value : the docker hub (e.g. https://hub.docker.com)
Only publicly accessible repositories are supported.
	`,
	Run: func(cmd *cobra.Command, args []string) {
		var registryURL, externalRepositoryName, repositoryName string
		switch len(args) {
		case 2:
			repositoryName = args[0]
			registryURL = ""
			externalRepositoryName = args[1]
		case 3:
			repositoryName = args[0]
			registryURL = args[1]
			externalRepositoryName = args[2]

		default:
			fmt.Fprintln(os.Stderr, "Invalid usage. sail repository add [<applicationName>/]<repositoryName> [<registryURL>/][<user>/]<externalRepositoryName>[:<tag>]. Please see sail repository add --help")
			return
		}

		n := repositoryAddStruct{
			RegistryURL:            registryURL,
			ExternalRepositoryName: externalRepositoryName,
		}
		repositoryAdd(repositoryName, n)
	},
}
{'fraction_non_alphanumeric': 0.1162046908315565, 'fraction_numerical': 0.006929637526652452, 'mean_word_length': 4.854914196567862, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4356234', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1088, 'n_words': 322}