#!/usr/bin/env perl

use lib ($ENV{RLWRAP_FILTERDIR} or ".");
use RlwrapFilter;
use strict;

my $N = 0;


my $filter = new RlwrapFilter;
my $name = $filter -> name;

$filter -> help_text("Usage: rlwrap -z $name <command>\n".
		     "replace prompt by simple counter\n".
		     "(demonstrates some simple prompt-munging techniques)");

$filter -> prompt_handler (\&munge_prompt); 

# This handler doesn't do anything, but it ensures that output is regeitered in $filter -> preious_tag:
$filter -> output_handler (sub {$_});

$filter -> run;


sub munge_prompt {
  my ($prompt) = @_;
  if ($filter -> previous_tag == TAG_OUTPUT) {
    $N++;
    return "prompt $N > ";
  } else {
    return $prompt;
  }
}
