JakkuSakura/kafcat

Cannot set offset to -1

Opened this issue · 3 comments

Hey, love the rust version!

However, I have a problem: I'm trying to set the offset to -1 in consumer mode like this:
kafcat -C -o -1 -b <broker> -t <topic>
And I get this error:

error: Found argument '-1' which wasn't expected, or isn't valid in this context

        If you tried to supply `-1` as a value rather than a flag, use `-- -1`

USAGE:
    kafcat {consume|-C} [OPTIONS] --topic <topic>

For more information try --help

Could you help me out how to input negative offsets?

it's the same as --offset=-1
Maybe you can try -o=-1 but I'm not sure

Wow, such fast reply!

For --offset=-1, the error is:

error: Found argument '--offset' which wasn't expected, or isn't valid in this context

        If you tried to supply `--offset` as a value rather than a flag, use `-- --offset`

USAGE:
    kafcat {consume|-C} [OPTIONS] --topic <topic>

For more information try --help

for -o=-1 it is a nasty panic:

16:50:00.874 (t: main) INFO - kafcat - Starting Consumer
16:50:00.875 (t: main) INFO - kafcat::rdkafka_impl - set offset Offset(-1)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: KafkaError (Set partition offset error: InvalidArgument (Local: Invalid argument or configuration))', /home/oliver/.cargo/registry/src/github.com-1ecc6299db9ec823/kafcat-0.1.2/src/rdkafka_impl.rs:107:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

for --offset=-1 this is a bug in configs.rs, easy fix.

for -1 offset,
I was converting it to this

            KafkaOffset::Offset(o) => Offset::OffsetTail((-o - 1) as _),

Maybe I'm wrong with OffsetTail's semantics
The alternative is to calculate the positive offset(not implemented)

try -o=end