Skip to content

Commit

Permalink
mc: Inherit global flags for initialization messages. (#2189)
Browse files Browse the repository at this point in the history
Fixes #2089
  • Loading branch information
harshavardhana authored Jun 26, 2017
1 parent d01a50d commit 05f588f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ func initMC() {
err := saveMcConfig(newMcConfig())
fatalIf(err.Trace(), "Unable to save new mc config.")

console.Infoln("Configuration written to `" + mustGetMcConfigPath() + "`. Please update your access credentials.")
if !globalQuiet && !globalJSON {
console.Infoln("Configuration written to `" + mustGetMcConfigPath() + "`. Please update your access credentials.")
}
}

// Check if mc session folder exists.
Expand Down Expand Up @@ -218,12 +220,12 @@ func registerBefore(ctx *cli.Context) error {
// Migrate any old version of config / state files to newer format.
migrate()

// Initialize default config files.
initMC()

// Set global flags.
setGlobalsFromContext(ctx)

// Initialize default config files.
initMC()

// Check if config can be read.
checkConfig()

Expand Down
12 changes: 9 additions & 3 deletions cmd/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,26 @@ func initShareConfig() {
if !isShareDirExists() {
fatalIf(createShareDir().Trace(mustGetShareDir()),
"Failed to create share `"+mustGetShareDir()+"` folder.")
console.Infof("Successfully created `%s`.\n", mustGetShareDir())
if !globalQuiet && !globalJSON {
console.Infof("Successfully created `%s`.\n", mustGetShareDir())
}
}

// Uploads share file.
if !isShareUploadsExists() {
fatalIf(initShareUploadsFile().Trace(getShareUploadsFile()),
"Failed to initialize share uploads `"+getShareUploadsFile()+"` file.")
console.Infof("Initialized share uploads `%s` file.\n", getShareUploadsFile())
if !globalQuiet && !globalJSON {
console.Infof("Initialized share uploads `%s` file.\n", getShareUploadsFile())
}
}

// Downloads share file.
if !isShareDownloadsExists() {
fatalIf(initShareDownloadsFile().Trace(getShareDownloadsFile()),
"Failed to initialize share downloads `"+getShareDownloadsFile()+"` file.")
console.Infof("Initialized share downloads `%s` file.\n", getShareDownloadsFile())
if !globalQuiet && !globalJSON {
console.Infof("Initialized share downloads `%s` file.\n", getShareDownloadsFile())
}
}
}

0 comments on commit 05f588f

Please sign in to comment.