<commit_before>package ch.deletescape.jterm.commandcontexts;

import ch.deletescape.jterm.CommandUtils;
import ch.deletescape.jterm.config.Resources;
import ch.deletescape.jterm.io.Printer;
import net.objecthunter.exp4j.ExpressionBuilder;

public class Misc extends CommandContext {

  @Override
  protected void init() {
    CommandUtils.addListener("calc", this::calc);
    CommandUtils.addListener("help", this::help);
    CommandUtils.addListener("echo", this::echo);
  }

  double calc(String cmd) {
    String operation = CommandUtils.parseInlineCommands(cmd);
    double result = new ExpressionBuilder(operation).build().evaluate();
    Printer.out.println(result);
    return result;
  }

  private String help(String arg) {
    String command = CommandUtils.parseInlineCommands(arg);
    StringBuilder output = new StringBuilder();
    if (arg.isEmpty()) {
      output.append(Resources.getString("Misc.HelpTitle"));
      CommandUtils.BASE_COMMANDS.stream().sorted().forEach(s -> appendCommand(output, s));
    } else {
      String help = Resources.getHelp(command, false);
      if (help.isEmpty()) {
        help = String.format(Resources.getString("Misc.NoHelpFound"), command);
      }<commit_msg>Add missing linebreak in help command<commit_after>package ch.deletescape.jterm.commandcontexts;

import ch.deletescape.jterm.CommandUtils;
import ch.deletescape.jterm.config.Resources;
import ch.deletescape.jterm.io.Printer;
import net.objecthunter.exp4j.ExpressionBuilder;

public class Misc extends CommandContext {

  @Override
  protected void init() {
    CommandUtils.addListener("calc", this::calc);
    CommandUtils.addListener("help", this::help);
    CommandUtils.addListener("echo", this::echo);
  }

  double calc(String cmd) {
    String operation = CommandUtils.parseInlineCommands(cmd);
    double result = new ExpressionBuilder(operation).build().evaluate();
    Printer.out.println(result);
    return result;
  }

  private String help(String arg) {
    String command = CommandUtils.parseInlineCommands(arg);
    StringBuilder output = new StringBuilder();
    if (arg.isEmpty()) {
      output.append(Resources.getString("Misc.HelpTitle") + "\n");
      CommandUtils.BASE_COMMANDS.stream().sorted().forEach(s -> appendCommand(output, s));
    } else {
      String help = Resources.getHelp(command, false);
      if (help.isEmpty()) {
        help = String.format(Resources.getString("Misc.NoHelpFound"), command);
      }
{'fraction_non_alphanumeric': 0.1270875763747454, 'fraction_numerical': 0.000814663951120163, 'mean_word_length': 4.445676274944567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1461173', 'n_tokens_mistral': 701, 'n_tokens_neox': 703, 'n_words': 136}