fix cli port auto detection to use right key, and add generic json comman interface