@@ -39,7 +39,7 @@ int main(int argc, char** argv)
3939 .Add <bool >(" overwrite" , " ow" , " Format overwrite the input file" )
4040 .Add <std::string>(" workspace" , " w" ,
4141 " Specify workspace directory,if no input file is specified, bulk formatting is performed" )
42- .Add <int >(" stdin" , " i" , " Read from stdin and specify read size" )
42+ .Add <bool >(" stdin" , " i" , " Read from stdin and specify read size" )
4343 .Add <std::string>(" config" , " c" ,
4444 " Specify .editorconfig file, it decides on the effect of formatting" )
4545 .Add <bool >(" detect-config" , " d" ,
@@ -87,26 +87,25 @@ int main(int argc, char** argv)
8787 if (cmd.HasOption (" file" ) || cmd.HasOption (" stdin" ))
8888 {
8989 auto luaFormat = std::make_shared<LuaFormat>();
90- if (cmd.HasOption (" file" ))
90+ if (cmd.HasOption (" file" ) && !cmd. HasOption ( " stdin " ) )
9191 {
9292 if (!luaFormat->SetInputFile (cmd.Get <std::string>(" file" )))
9393 {
9494 std::cerr << Util::format (" Can not find file {}" , cmd.Get <std::string>(" file" )) << std::endl;
9595 return -1 ;
9696 }
9797 }
98- else if (cmd.HasOption (" stdin" ))
98+ else if (cmd.HasOption (" stdin" ) && !cmd. HasOption ( " file " ) )
9999 {
100100 SET_BINARY_MODE ();
101- std::size_t size = cmd.Get <int >(" stdin" );
102- if (!luaFormat->ReadFromStdin (size))
101+ if (!luaFormat->ReadFromStdin ())
103102 {
104103 return -1 ;
105104 }
106105 }
107106 else
108107 {
109- std::cerr << " not special input file " << std::endl;
108+ std::cerr << " Either --file or --stdin must be specified. " << std::endl;
110109 return -1 ;
111110 }
112111
0 commit comments