Refactor command-line parser and add version flag to k, klr and kpm