add name argument and fix the meaning of --dir option