package de.larsgrefer.sense_hat.tester.command;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import de.larsgrefer.sense_hat.SenseHat;
import de.larsgrefer.sense_hat.SenseHatColor;
import de.larsgrefer.sense_hat.TextDisplay;
import de.larsgrefer.sense_hat.tester.Command;

import java.io.IOException;
import java.time.Duration;
import java.util.List;

@Parameters(commandDescription = "Show Text", separators = "=")
public class TextCommand implements Command {

    @Parameter
    private List<String> text;

    @Parameter(names = {"--color", "--foreground"})
    private String color;

    @Parameter(names = {"--background"})
    private String background;

    @Parameter(names = {"--duration"})
    private int duration;

    @Override
    public void run(SenseHat senseHat) throws IOException {
        TextDisplay textDisplay = new TextDisplay(senseHat);

        textDisplay.setForeground(SenseHatColor.fromString(this.color));
        textDisplay.setBackground(SenseHatColor.fromString(this.background));
        textDisplay.setDuration(Duration.ofMillis(duration));

        for (String line : text) {
            textDisplay.displayText(line);
        }
    }
}

@@ -613,18 +613,26 @@
 ng color
+ = %22FFF%22
 ;%0A
-
 %0A    @Pa
@@ -694,16 +694,24 @@
 ckground
+ = %22000%22
 ;%0A%0A    @
@@ -768,16 +768,22 @@
 duration
+ = 250
 ;%0A%0A    @
@@ -851,16 +851,16 @@
 ption %7B%0A
-
         
@@ -909,24 +909,25 @@
 senseHat);%0A%0A
+%0A
         text

fix tester