/*
 * Copyright (C) 2009 the original author(s).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.sonatype.gshell;

import org.fusesource.jansi.Ansi;
import org.sonatype.gshell.branding.BrandingSupport;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Branding for <tt>gsh</tt>.
 * 
 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
 */
public class BrandingImpl
    extends BrandingSupport
{
    // Figlet font name: ???
    private static final String[] BANNER = {
        "   ____ ____  _          _ _ ",
        "  / ___/ ___|| |__   ___| | |",
        " | |  _\\___ \\| '_ \\ / _ \\ | |",
        " | |_| |___) | | | |  __/ | |",
        "  \\____|____/|_| |_|\\___|_|_|",
    };
   
    /*
    // Figlet font name: Georgia11
    private static final String[] BANNER = {
        "                          ,,                 ,,    ,,",
        "   .g8\"\"\"bgd   .M\"\"\"bgd `7MM               `7MM  `7MM",
        " .dP'     `M  ,MI    \"Y   MM                 MM    MM",
        " dM'       `  `MMb.       MMpMMMb.  .gP\"Ya   MM    MM",
        " MM             `YMMNq.   MM    MM ,M'   Yb  MM    MM",
        " MM.    `7MMF'.     `MM   MM    MM 8M\"\"\"\"\"\"  MM    MM",
        " `Mb.     MM  Mb     dM   MM    MM YM.    ,  MM    MM",
        "   `\"bmmmdPY  P\"Ybmmd\"  .JMML  JMML.`Mbmmd'.JMML..JMML."
    };
    */

    @Override
    public String getWelcomeMessage() {
        StringWriter writer = new StringWriter();
        PrintWriter out = new PrintWriter(writer);

        for (String line : BANNER) {
            out.println(Ansi.ansi().fg(Ansi.Color.CYAN).a(line).reset());
        }

        out.println();
        out.format("%s (%s)", getDisplayName(), getVersion()).println();
        out.println();
        out.println("Type '@|bold help|@' for more information.");
        out.print(line());
        out.flush();

        return writer.toString();
    }

    @Override
    public String getDisplayName() {
        return getMessages().format("displayName");
    }

    @Override
    public String getGoodbyeMessage() {
        return getMessages().format("goodbye");
    }

    @Override
    public File getUserContextDir() {
        return resolveFile(new File(getUserHomeDir(), ".gshell"));
    }
}
@@ -722,58 +722,54 @@
 rt;%0A
-%0A
 import 
-java.io.File;%0Aimport java.io
+org.sonatype.gshell.util
 .Print
-Writ
+Buff
 er;%0A
+%0A
 impo
@@ -779,28 +779,20 @@
 java.io.
-StringWriter
+File
 ;%0A%0A/**%0A 
@@ -888,16 +888,30 @@
 lon%3C/a%3E%0A
+ * @since 2.0%0A
  */%0Apubl
@@ -1964,98 +1964,43 @@
     
-StringWriter writer = new StringWriter();%0A        PrintWriter out = new PrintWriter(writer
+PrintBuffer buff = new PrintBuffer(
 );%0A%0A
@@ -2040,35 +2040,36 @@
 ) %7B%0A            
-out
+buff
 .println(Ansi.an
@@ -2122,35 +2122,36 @@
      %7D%0A%0A        
-out
+buff
 .println();%0A    
@@ -2154,19 +2154,20 @@
         
-out
+buff
 .format(
@@ -2220,35 +2220,36 @@
 ntln();%0A        
-out
+buff
 .println();%0A    
@@ -2248,27 +2248,28 @@
 ();%0A        
-out
+buff
 .println(%22Ty
@@ -2320,19 +2320,20 @@
         
-out
+buff
 .print(l
@@ -2352,11 +2352,12 @@
     
-out
+buff
 .flu
@@ -2382,14 +2382,12 @@
 urn 
-writer
+buff
 .toS

Use PrintBuffer