这是indexloc提供的服务,不要输入任何密码
Skip to content

Simplify internal config functions to reduce duplication #2966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions plugins/config/subcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,32 +136,30 @@ func CommandBundle(args []string, global bool, merged bool) {

//getEnvironment for the given app (global config if appName is empty). Merge with global environment if merged is true.
func getEnvironment(appName string, merged bool) (env *Env) {
env, err := loadAppOrGlobalEnv(appName)
if err != nil {
common.LogFail(err.Error())
}
var err error
if appName != "" && merged {
env, err = LoadMergedAppEnv(appName)
if err != nil {
common.LogFail(err.Error())
}
} else {
env, err = loadAppOrGlobalEnv(appName)
}
if err != nil {
common.LogFail(err.Error())
}
return env
}

//getCommonArgs extracts common positional args (appName and keys)
func getCommonArgs(global bool, args []string) (appName string, keys []string) {
nextArg := 0
keys = args
if !global {
if len(args) > 0 {
appName = args[0]
}
if appName == "" {
common.LogFail("Please specify an app or --global")
} else {
nextArg++
keys = args[1:]
}
}
keys = args[nextArg:]
return appName, keys
}