<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-docopt"
	"github.com/flynn/flynn/controller/client"
	ct "github.com/flynn/flynn/controller/types"
)

func init() {
	register("release", runRelease, `
usage: flynn release add [-t <type>] [-f <file>] <uri>

Manage app releases.

Options:
   -t <type>          type of the release. Currently only 'docker' is supported. [default: docker]
   -f, --file <file>  release configuration file
Commands:
   add   add a new release
`)
}

func runRelease(args *docopt.Args, client *controller.Client) error {
	if args.Bool["add"] {
		if args.String["-t"] == "docker" {
			return runReleaseAddDocker(args, client)
		} else {
			return fmt.Errorf("Release type %s not supported.", args.String["-t"])
		}
	}
	return fmt.Errorf("Top-level command not implemented.")<commit_msg>cli: Document creating new releases using images.<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"

	"github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-docopt"
	"github.com/flynn/flynn/controller/client"
	ct "github.com/flynn/flynn/controller/types"
)

func init() {
	register("release", runRelease, `
usage: flynn release add [-t <type>] [-f <file>] <uri>

Manage app releases.

Options:
   -t <type>          type of the release. Currently only 'docker' is supported. [default: docker]
   -f, --file <file>  release configuration file

Commands:
   add   add a new release

      Create a new release from a Docker image.

      The optional file argument takes a path to a file containing release
      configuration in a JSON format. It's primarily used for specifying the
      release environment and processes (similar to a Procfile). It can take any
      of the arguments the controller Release type can take.

Examples:

   Release an echo server using the flynn/slugbuilder image as a base, running socat.

   $ cat config.json
	{
		"env": {"MY_VAR": "Hello World, this will be available in all process types."},
		"processes": {
			"echo": {
				"cmd": ["socat -v tcp-l:$PORT,fork exec:/bin/cat"],
				"entrypoint": ["sh", "-c"],
				"env": {"ECHO": "This var is specific to the echo process type."},
				"ports": [{"proto": "tcp"}]
			}
		}
	}
   $ flynn release add -f config.json https://registry.hub.docker.com/flynn/slugbuilder?id=15d72b7f573b
   Created release f55fde802170.
`)
}

func runRelease(args *docopt.Args, client *controller.Client) error {
	if args.Bool["add"] {
		if args.String["-t"] == "docker" {
			return runReleaseAddDocker(args, client)
		} else {
			return fmt.Errorf("Release type %s not supported.", args.String["-t"])
		}
	}
	return fmt.Errorf("Top-level command not implemented.")
{'fraction_non_alphanumeric': 0.1381294964028777, 'fraction_numerical': 0.0057553956834532375, 'mean_word_length': 3.5966942148760332, 'pattern_counts': {'":': 10, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '2303175', 'n_tokens_mistral': 983, 'n_tokens_neox': 915, 'n_words': 278}