For example, with the buffer abcdef and selection bcd, with cursor on the right end:
commandline --selection-anchor should output 1;
commandline --selection-anchor 2 should switch selection to cd,
commandline --selection-anchor 3 --cursor 2 should select cd, but also swap the beginning and end of selection to backwards.
UPD fixed: --selection-anchor 3 in the last line example