1
0
mirror of https://github.com/minio/mc.git synced 2025-11-16 11:02:34 +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 runCatCmd(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "cat", 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: fmt.Sprintf("Unable to read config file %s", mustGetMcConfigPath()),
Error: iodine.New(err, nil),
})
@@ -48,7 +48,7 @@ func runCatCmd(ctx *cli.Context) {
// Convert arguments to URLs: expand alias, fix format...
urls, err := getExpandedURLs(ctx.Args(), config.Aliases)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: fmt.Sprintf("Unknown type of URL %s", urls),
Error: iodine.New(err, nil),
})
@@ -57,14 +57,14 @@ func runCatCmd(ctx *cli.Context) {
sourceURLs := urls
sourceURLConfigMap, err := getHostConfigs(sourceURLs)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: fmt.Sprintf("Unable to read host configuration for %s from config file %s", sourceURLs, mustGetMcConfigPath()),
Error: iodine.New(err, nil),
})
}
humanReadable, err := doCatCmd(sourceURLConfigMap)
if err != nil {
console.Fatalln(ErrorMessage{
console.Fatals(ErrorMessage{
Message: humanReadable,
Error: iodine.New(err, nil),
})