// New new home app
549916
func New(config *Config) *App {
	if config.Prefix == "" {
		config.Prefix = "/api"
	}
	return &App{Config: config}
}
683989
func newApp(c *model.CommandConfig) (err error) {
	// Check for an existing folder so we don't clobber it
	_, err = build.Import(c.ImportPath, "", build.FindOnly)
	if err == nil || !utils.Empty(c.AppPath) {
		return utils.NewBuildError("Abort: Import path already exists.", "path", c.ImportPath)
	}

	// checking and setting skeleton
	if err=setSkeletonPath(c);err!=nil {
		return
	}

	// Create application path
	if err := os.MkdirAll(c.AppPath, os.ModePerm); err != nil {
		return utils.NewBuildError("Abort: Unable to create app path.", "path", c.AppPath)
	}

	if c.New.Vendored {
		utils.Logger.Info("Creating a new vendor app")

		vendorPath := filepath.Join(c.AppPath, "vendor")
		if !utils.DirExists(vendorPath) {

			if err := os.MkdirAll(vendorPath, os.ModePerm); err != nil {
				return utils.NewBuildError("Failed to create "+vendorPath, "error", err)
			}
		}

		// In order for dep to run there needs to be a source file in the folder
		tempPath := filepath.Join(c.AppPath, "tmp")
		utils.Logger.Info("Checking for temp folder for source code", "path", tempPath)
		if !utils.DirExists(tempPath) {
			if err := os.MkdirAll(tempPath, os.ModePerm); err != nil {
				return utils.NewBuildIfError(err, "Failed to create "+vendorPath)
			}

			if err = utils.GenerateTemplate(filepath.Join(tempPath, "main.go"), NEW_MAIN_FILE, nil); err != nil {
				return utils.NewBuildIfError(err, "Failed to create main file "+vendorPath)
			}
		}

		// Create a package template file if it does not exist
		packageFile := filepath.Join(c.AppPath, "Gopkg.toml")
		utils.Logger.Info("Checking for Gopkg.toml", "path", packageFile)
		if !utils.Exists(packageFile) {
			utils.Logger.Info("Generating Gopkg.toml", "path", packageFile)
			if err := utils.GenerateTemplate(packageFile, VENDOR_GOPKG, nil); err != nil {
				return utils.NewBuildIfError(err, "Failed to generate template")
			}
		} else {
			utils.Logger.Info("Package file exists in skeleto, skipping adding")
		}

		getCmd := exec.Command("dep", "ensure", "-v")
		utils.CmdInit(getCmd, c.AppPath)

		utils.Logger.Info("Exec:", "args", getCmd.Args, "env", getCmd.Env, "workingdir",getCmd.Dir)
		getOutput, err := getCmd.CombinedOutput()
		if err != nil {
			return utils.NewBuildIfError(err, string(getOutput))
		}
	}

	// checking and setting application
	if err = setApplicationPath(c); err != nil {
		return err
	}
	// At this point the versions can be set
	c.SetVersions()

	// copy files to new app directory
	if err = copyNewAppFiles(c);err != nil {
		return
	}

	// Rerun the dep tool if vendored
	if c.New.Vendored {
		getCmd := exec.Command("dep", "ensure", "-v")
		utils.CmdInit(getCmd, c.AppPath)
		utils.Logger.Info("Exec:", "args", getCmd.Args)
		getOutput, err := getCmd.CombinedOutput()
		if err != nil {
			utils.Logger.Fatal(string(getOutput))
		}
	}

	// goodbye world
	fmt.Fprintln(os.Stdout, "Your application has been created in:\n  ", c.AppPath)
	// Check to see if it should be run right off
	if c.New.Run {
		runApp(c)
	} else {
		fmt.Fprintln(os.Stdout, "\nYou can run it with:\n   revel run -a ", c.ImportPath)
	}
	return
}
1086217
func NewConfig(appName, fileName string) *Conf {
	if appName == "" {
		panic("appName.required")
	}

	if fileName == "" {
		fileName = "conf.json"
	}

	c := new(Conf)
	c.dirPath = fmt.Sprintf("%s/.%s", os.Getenv("HOME"), appName)
	c.fileName = fileName

	c.initConfig()

	return c
}
339857
func (s *MyHeritage) New(appEnv *cfenv.App) *MyHeritage {
	heritageAdminServiceName := os.Getenv("UPS_PEZ_HERITAGE_ADMIN_NAME")
	heritageLoginTargetName := os.Getenv("HERITAGE_LOGIN_TARGET_NAME")
	heritageLoginUserName := os.Getenv("HERITAGE_LOGIN_USER_NAME")
	heritageLoginPassName := os.Getenv("HERITAGE_LOGIN_PASS_NAME")
	heritageCCTargetName := os.Getenv("HERITAGE_CC_TARGET_NAME")
	heritageAdminService, err := appEnv.Services.WithName(heritageAdminServiceName)

	if err != nil {
		panic(fmt.Sprintf("heritage service name error: %s", err.Error()))
	}
	s.LoginTarget = heritageAdminService.Credentials[heritageLoginTargetName].(string)
	s.LoginUser = heritageAdminService.Credentials[heritageLoginUserName].(string)
	s.LoginPass = heritageAdminService.Credentials[heritageLoginPassName].(string)
	s.CCTarget = heritageAdminService.Credentials[heritageCCTargetName].(string)
	return s
}
1320947
func (c *Client) CreateApp(req AppCreateRequest) (App, error) {
	var appResp AppResource
	buf := bytes.NewBuffer(nil)
	err := json.NewEncoder(buf).Encode(req)
	if err != nil {
		return App{}, err
	}
	r := c.NewRequestWithBody("POST", "/v2/apps", buf)
	resp, err := c.DoRequest(r)
	if err != nil {
		return App{}, errors.Wrapf(err, "Error creating app %s", req.Name)
	}
	if resp.StatusCode != http.StatusCreated {
		return App{}, errors.Wrapf(err, "Error creating app %s, response code: %d", req.Name, resp.StatusCode)
	}
	resBody, err := ioutil.ReadAll(resp.Body)
	defer resp.Body.Close()
	if err != nil {
		return App{}, errors.Wrapf(err, "Error reading app %s http response body", req.Name)
	}
	err = json.Unmarshal(resBody, &appResp)
	if err != nil {
		return App{}, errors.Wrapf(err, "Error deserializing app %s response", req.Name)
	}
	return c.mergeAppResource(appResp), nil
}
586251
func New(b *bootstrap.Bootstrapper) iris.Handler {
	return func(ctx iris.Context) {
		// response headers
		ctx.Header("App-Name", b.AppName)
		ctx.Header("App-Owner", b.AppOwner)
		ctx.Header("App-Since", time.Since(b.AppSpawnDate).String())

		ctx.Header("Server", "Iris: https://iris-go.com")

		// view data if ctx.View or c.Tmpl = "$page.html" will be called next.
		ctx.ViewData("AppName", b.AppName)
		ctx.ViewData("AppOwner", b.AppOwner)
		ctx.Next()
	}
}
1176224
func NewApp() *App {
	return &App{
		Name:         filepath.Base(os.Args[0]),
		HelpName:     filepath.Base(os.Args[0]),
		Usage:        "A new cli application",
		UsageText:    "",
		Version:      "0.0.0",
		BashComplete: DefaultAppComplete,
		Action:       helpCommand.Action,
		Compiled:     compileTime(),
		Writer:       os.Stdout,
	}
}
1121984
func NewAppInput(rd io.Reader) app.Input {
	return app.Input(NewInputSize(rd, defaultBufSize))
}
779356
func HomeDir() (home string, err error) {
	if runtime.GOOS == "windows" {
		home = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
		if home == "" {
			home = os.Getenv("USERPROFILE")
		}
	} else {
		home = os.Getenv("HOME")
	}

	if len(home) == 0 {
		return "", errors.New("Cannot specify home directory because it's empty")
	}

	return home, nil
}
251452
func New(apiKey string) *Handler {
	return NewFromNotifier(bugsnag.New(bugsnag.Configuration{
		APIKey: apiKey,
	}))
}
834849
func newApp() *todoApp {
	result := &todoApp{}
	//init the list, setting our own object as the joiner (we meet
	//the interface Joiner)
	result.todos = s5.NewList(result)

	//create initial values of attributes
	result.numNotDone = s5.NewIntegerSimple(0)
	result.plural = s5.NewStringSimple("")
	result.someDone = s5.NewBooleanSimple(false)
	result.numDone = s5.NewIntegerSimple(0)

	//done create app object
	return result
}
1051752
func NewApp(options MockupOptions) (app.App, error) {
	mapp := &MockupApp{
		options: options,
	}
	if err := mapp.initEngineScope(); err != nil {
		return nil, err
	}
	if err := mapp.initArgsScope(); err != nil {
		return nil, err
	}
	if err := mapp.initFilespaceScope(); err != nil {
		return nil, err
	}
	if err := mapp.initConfigScope(); err != nil {
		return nil, err
	}
	if err := mapp.initDependencyScope(); err != nil {
		return nil, err
	}
	if err := mapp.initAppScope(); err != nil {
		return nil, err
	}
	if err := mapp.initCommandScope(); err != nil {
		return nil, err
	}
	mapp.options.DP.SetDefault(app.EngineScope, mapp.options.EngineScope)
	mapp.options.DP.SetDefault(app.ArgsScope, mapp.options.ArgsScope)
	mapp.options.DP.SetDefault(app.FilespaceScope, mapp.options.FilespaceScope)
	mapp.options.DP.SetDefault(app.ConfigScope, mapp.options.ConfigScope)
	mapp.options.DP.SetDefault(app.DependencyScope, mapp.options.DependencyScope)
	mapp.options.DP.SetDefault(app.AppScope, mapp.options.AppScope)
	mapp.options.DP.SetDefault(app.CommandScope, mapp.options.CommandScope)
	mapp.options.DP.SetDefault(app.InputService, mapp.options.Input)
	mapp.options.DP.SetDefault(app.OutputService, mapp.options.Output)
	mapp.options.DP.AddInjectors([]dependency.Injector{
		mapp.options.CommandScope,
		mapp.options.AppScope,
		mapp.options.ConfigScope,
		mapp.options.FilespaceScope,
		mapp.options.ArgsScope,
		mapp.options.EngineScope,
	})
	return mapp, nil
}
283530
func NewAppLog(loggerName string, msg []byte) *AppLog {
	now := time.Now().UTC()
	return &AppLog{
		Timestamp:  now.UnixNano(),
		Time:       now.Format(time.RFC3339),
		Type:       "app.log",
		Logger:     loggerName,
		Hostname:   hostname,
		EnvVersion: "2.0",
		Pid:        os.Getpid(),
		Fields: map[string]interface{}{
			"msg": string(bytes.TrimSpace(msg)),
		},
	}
}
106743
func NewApp(binPath string, paths *model.RevelContainer) *App {
	return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort}
}
131163
func NewApps(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.LayoutsStore {
	return &Apps{
		Dir:      dir,
		Load:     loadFile,
		Filename: fileName,
		Create:   createLayout,
		ReadDir:  ioutil.ReadDir,
		Remove:   os.Remove,
		IDs:      ids,
		Logger:   logger,
	}
}
223012
func (d *Dock) NewMenu(i []*MenuItemOptions) *Menu {
	return newMenu(d.ctx, d.id, i, d.c, d.d, d.i, d.w)
}
1367378
func New(name, help string) *Application {
	a := &Application{
		Name:          name,
		Help:          help,
		errorWriter:   os.Stderr, // Left for backwards compatibility purposes.
		usageWriter:   os.Stderr,
		usageTemplate: DefaultUsageTemplate,
		terminate:     os.Exit,
	}
	a.flagGroup = newFlagGroup()
	a.argGroup = newArgGroup()
	a.cmdGroup = newCmdGroup(a)
	a.HelpFlag = a.Flag("help", "Show context-sensitive help (also try --help-long and --help-man).")
	a.HelpFlag.Bool()
	a.Flag("help-long", "Generate long help.").Hidden().PreAction(a.generateLongHelp).Bool()
	a.Flag("help-man", "Generate a man page.").Hidden().PreAction(a.generateManPage).Bool()
	a.Flag("completion-bash", "Output possible completions for the given args.").Hidden().BoolVar(&a.completion)
	a.Flag("completion-script-bash", "Generate completion script for bash.").Hidden().PreAction(a.generateBashCompletionScript).Bool()
	a.Flag("completion-script-zsh", "Generate completion script for ZSH.").Hidden().PreAction(a.generateZSHCompletionScript).Bool()

	return a
}