package example;

import com.simplifyops.toolbelt.*;

import java.io.IOException;

/**
 * Created by greg on 7/5/16.
 */
@SubCommand
public class App {

    public static void main(String[] args) throws IOException, CommandRunFailure {
        ToolBelt.belt("example")
                .ansiColorOutput(System.getenv("NOCOLOR") == null)
                .defaultHelpCommands()
                .add(
                        new App(),
                        new Sub()
                )
                .commandInput(new SimpleCommandInput())
                .buckle().runMain(args, true);
    }

    @Command(description = "Start here, run: example begin")
    public void begin() {
        System.out.println("Easily create commandlines with simple annotation");
        System.out.println();
        System.out.println("next try: example colorize");
    }

    @Command
    public void colorize(CommandOutput output) {
        output.output("Control output, and ansi colorization");
        output.warning("If you enable it");
        output.output(ANSIColorOutput.colorize(
                "You can even ",
                ANSIColorOutput.Color.BLUE,
                "get fancy",
                " if you want to."
        ));
        output.output("");
        output.output("Try setting NOCOLOR=1 in your environment, and run: `example colorize` again");
        output.output("");
        output.output(ANSIColorOutput.colorize(
                "next try: ",
                ANSIColorOutput.Color.RED,
                "example fail"
        ));

    }

    @Command(description = "Demonstrate failure")
    public boolean fail(CommandOutput output) {
        output.error("Return false, or throw an exception, to fail");
        output.warning("The exit code should be: 2");
        output.output("next try: example sub");
        return false;
    }


}

@@ -250,23 +250,13 @@
 elt.
-belt(%22example%22)
+with(
 %0A   
@@ -272,128 +272,19 @@
     
-.ansiColorOutput(System.getenv(%22NOCOLOR%22) == null)%0A                .defaultHelpCommands()%0A                .add(%0A        
+%22example%22,%0A
     
@@ -318,32 +318,24 @@
             
-        
 new Sub()%0A  
@@ -344,98 +344,8 @@
     
-   
-     )%0A                .commandInput(new SimpleCommandInput())%0A                .buckle(
 ).ru
@@ -1070,17 +1070,17 @@
 ing 
-NOCOLOR=1
+TERM=blah
  in 

simplify example app