#!/usr/bin/expect -f

set action [lindex $argv 0]
set since [lindex $argv 1]
set since_val [lindex $argv 2]

spawn -noecho sh -c "abrt-cli p $since $since_val && sleep 0.5"

set timeout 10

# timeout handler
proc itstime {args} {
    puts "!! expect timeout !!"
        exit 1
}

while {1} {
    expect {

        eof {break}

        timeout { itstime }

        "Actions: remove(rm), report(e), info(i), skip(s):" {
            send "$action\n"
        }
        "Actions: remove(rm), info(i), skip(s):" {
            send "$action\n"
        }
       "For next problem press ENTER:" {
            send "\n"
        }
    }
}

