1
0
mirror of https://github.com/minio/mc.git synced 2025-11-14 23:42:27 +03:00

Implement console.Fatals, Errors, Infos, Prints for structure input and printing

This commit is contained in:
Harshavardhana
2015-05-26 17:56:36 -07:00
parent 3e24f7ae21
commit 25f847b3b6
11 changed files with 156 additions and 85 deletions

View File

@@ -33,14 +33,14 @@ func runMakeBucketCmd(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "mb", 1) // last argument is exit code
}
if !isMcConfigExist() {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Please run \"mc config generate\"",
Error: errors.New("\"mc\" is not configured"),
})
}
config, err := getMcConfig()
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Unable to read config file " + mustGetMcConfigPath() + "",
Error: err,
})
@@ -51,12 +51,12 @@ func runMakeBucketCmd(ctx *cli.Context) {
if err != nil {
switch e := iodine.ToError(err).(type) {
case errUnsupportedScheme:
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: fmt.Sprintf("Unknown type of URL %s", e.url),
Error: e,
})
default:
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: fmt.Sprintf("Unable to parse argument %s", arg),
Error: err,
})
@@ -64,7 +64,7 @@ func runMakeBucketCmd(ctx *cli.Context) {
}
targetConfig, err := getHostConfig(targetURL)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: fmt.Sprintf("Unable to read host configuration for %s from config file %s", targetURL, mustGetMcConfigPath()),
Error: err,
})
@@ -74,7 +74,7 @@ func runMakeBucketCmd(ctx *cli.Context) {
for targetURL, targetConfig := range targetURLConfigMap {
errorMsg, err := doMakeBucketCmd(targetURL, targetConfig)
if err != nil {
console.Errorln(ErrorMessage{
console.Errors(ErrorMessage{
Message: errorMsg,
Error: err,
})