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

@@ -32,14 +32,14 @@ func runAccessCmd(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code
}
if !isMcConfigExist() {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Please run \"mc config generate\"",
Error: iodine.New(errors.New("\"mc\" is not configured"), nil),
})
}
config, err := getMcConfig()
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "loading config file failed",
Error: iodine.New(err, nil),
})
@@ -47,14 +47,14 @@ func runAccessCmd(ctx *cli.Context) {
targetURLConfigMap := make(map[string]*hostConfig)
targetURLs, err := getExpandedURLs(ctx.Args(), config.Aliases)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Unknown type of URL ",
Error: iodine.New(err, nil),
})
}
acl := bucketACL(ctx.Args().First())
if !acl.isValidBucketACL() {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Valid types are [private, public, readonly].",
Error: iodine.New(errors.New("Invalid ACL Type "+acl.String()+""), nil),
})
@@ -63,7 +63,7 @@ func runAccessCmd(ctx *cli.Context) {
for _, targetURL := range targetURLs {
targetConfig, err := getHostConfig(targetURL)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: "Unable to read configuration for host " + "" + targetURL + "",
Error: iodine.New(err, nil),
})
@@ -73,7 +73,7 @@ func runAccessCmd(ctx *cli.Context) {
for targetURL, targetConfig := range targetURLConfigMap {
errorMsg, err := doUpdateAccessCmd(targetURL, acl.String(), targetConfig)
if err != nil {
console.Errorln(ErrorMessage{
console.Errors(ErrorMessage{
Message: errorMsg,
Error: iodine.New(err, nil),
})