@@ -28,7 +28,7 @@ int main(int argc, char** argv)
2828 cmd.AddTarget (" format" )
2929 .Add <std::string>(" file" , " f" , " Specify the input file" )
3030 .Add <std::string>(" workspace" , " w" ,
31- " Specify workspace directory perform batch formatting" )
31+ " Specify workspace directory,if no input file is specified, bulk formatting is performed " )
3232 .Add <int >(" stdin" , " i" , " Read from stdin and specify read size" )
3333 .Add <std::string>(" config" , " c" ,
3434 " Specify .editorconfig file, it decides on the effect of formatting" )
@@ -41,7 +41,7 @@ int main(int argc, char** argv)
4141 cmd.AddTarget (" check" )
4242 .Add <std::string>(" file" , " f" , " Specify the input file" )
4343 .Add <std::string>(" workspace" , " w" ,
44- " Specify workspace directory perform batch checking" )
44+ " Specify workspace directory, if no input file is specified, bulk checking is performed " )
4545 .Add <std::string>(" config" , " c" ,
4646 " Specify editorconfig file, it decides on the effect of formatting or diagnosis" )
4747 .Add <bool >(" detect-config" , " d" ,
@@ -57,7 +57,7 @@ int main(int argc, char** argv)
5757 return -1 ;
5858 }
5959
60- if (! cmd.HasOption (" workspace " ))
60+ if (cmd.HasOption (" file " ))
6161 {
6262 auto luaFormat = std::make_shared<LuaFormat>();
6363 if (cmd.HasOption (" file" ))
@@ -90,7 +90,14 @@ int main(int argc, char** argv)
9090
9191 if (cmd.Get <bool >(" detect-config" ))
9292 {
93- luaFormat->AutoDetectConfig ();
93+ if (cmd.HasOption (" workspace" ))
94+ {
95+ luaFormat->AutoDetectConfig (std::filesystem::path (cmd.Get <std::string>(" workspace" )));
96+ }
97+ else
98+ {
99+ luaFormat->AutoDetectConfig ();
100+ }
94101 }
95102 else if (cmd.HasOption (" config" ))
96103 {
@@ -115,28 +122,28 @@ int main(int argc, char** argv)
115122 }
116123 }
117124 }
118- else
125+ else if (cmd. HasOption ( " workspace " ))
119126 {
120127 LuaWorkspaceFormat workspaceFormat (cmd.Get <std::string>(" workspace" ));
121128
122- if (cmd.Get <bool >(" detect-config" ))
129+ if (cmd.Get <bool >(" detect-config" ))
123130 {
124131 workspaceFormat.SetAutoDetectConfig (true );
125132 }
126- else if (cmd.HasOption (" config" ))
133+ else if (cmd.HasOption (" config" ))
127134 {
128135 workspaceFormat.SetConfigPath (cmd.Get <std::string>(" config" ));
129136 }
130137
131138 workspaceFormat.SetKeyValues (cmd.GetKeyValueOptions ());
132139
133- if (cmd.GetTarget () == " format" )
140+ if (cmd.GetTarget () == " format" )
134141 {
135142 workspaceFormat.ReformatWorkspace ();
136143 }
137- else if (cmd.GetTarget () == " check" )
144+ else if (cmd.GetTarget () == " check" )
138145 {
139- if (!workspaceFormat.CheckWorkspace () && cmd.Get <bool >(" diagnosis-as-error" ))
146+ if (!workspaceFormat.CheckWorkspace () && cmd.Get <bool >(" diagnosis-as-error" ))
140147 {
141148 return -1 ;
142149 }
0 commit comments