summaryrefslogtreecommitdiff
path: root/dice/src/example/java/bjc/dicelang/neodice/commands/ShowBindingsCommand.java
blob: fe2ac89d74a922c6c256dfea399a3f7607fdb854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package bjc.dicelang.neodice.commands;

import static bjc.dicelang.neodice.statements.VoidStatementValue.*;

import java.util.*;

import bjc.dicelang.neodice.*;
import bjc.dicelang.neodice.statements.*;

public class ShowBindingsCommand implements Command {
  @Override
  public StatementValue execute(Iterator<String> words, DieBoxCLI state) {
    state.output.printf("Showing all %d variables currently bound:", state.bindings.size());
    state.bindings.forEach((name, bound) -> {
      state.output.printf("\t%t\t%s\n", name, bound);
    });
    
    return VOID_INST;
  }
  
  @Override
  public String shortHelp() {
    return "print out all the variable bindings";
  }
  
  @Override
  public String longHelp() {
    return "Prints out all of the variable bindings that exist at the moment";
  }
}