Skip to content

Commit d71d6ab

Browse files
committed
修复无配置项bug
1 parent 51271ad commit d71d6ab

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

CodeFormat/src/CodeFormat.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ int main(int argc, char** argv)
4242
if (!cmd.Get<std::string>("file").empty())
4343
{
4444
parser = LuaParser::LoadFromFile(cmd.Get<std::string>("file"));
45+
if (!parser)
46+
{
47+
std::cerr << format("can not find file: {}", cmd.Get<std::string>("file")) << std::endl;
48+
}
4549
}
4650
else if (cmd.Get<int>("stdin") != 0)
4751
{
@@ -56,11 +60,16 @@ int main(int argc, char** argv)
5660
parser = LuaParser::LoadFromBuffer(std::move(buffer));
5761
}
5862

59-
std::shared_ptr<LuaCodeStyleOptions> options;
63+
std::shared_ptr<LuaCodeStyleOptions> options = nullptr;
64+
6065
if (!cmd.Get<std::string>("config").empty())
6166
{
6267
options = LuaCodeStyleOptions::ParseFromEditorConfig(cmd.Get<std::string>("config"));
6368
}
69+
else
70+
{
71+
options = std::make_shared<LuaCodeStyleOptions>();
72+
}
6473

6574
parser->BuildAstWithComment();
6675

0 commit comments

Comments
 (0)