rebase: factor out sub command handling