Skip to content

Commit 1e4c02b

Browse files
committed
Merge branch 'primary' of https://github.com/aatxe/lute into run-analysis
2 parents aae58a5 + 6403969 commit 1e4c02b

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

cli/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ int main(int argc, char** argv)
214214
program_argv = &argv[i + 1];
215215
break;
216216
}
217+
else if (argv[i][0] == '-' && argv[i][1] != '\0')
218+
continue;
217219

218220
if (parsingFiles)
219221
files.push_back(std::string(argv[i])); // fix: Explicit conversion

cli/tc.cpp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,60 @@ static bool reportModuleResult(Luau::Frontend& frontend, const Luau::ModuleName&
210210
return cr->errors.empty() && cr->lintResult.errors.empty();
211211
}
212212

213+
static std::string getExtension(const std::string& path)
214+
{
215+
size_t dot = path.find_last_of(".\\/");
216+
217+
if (dot == std::string::npos || path[dot] != '.')
218+
return "";
219+
220+
return path.substr(dot);
221+
}
213222

214-
int typecheck(const std::vector<std::string> sourceFiles)
223+
std::vector<std::string> processSourceFiles(const std::vector<std::string>& sourceFilesInput)
224+
{
225+
std::vector<std::string> files;
226+
227+
for (const auto& path :sourceFilesInput)
228+
{
229+
std::string normalized = normalizePath(path);
230+
231+
if (isDirectory(normalized))
232+
{
233+
traverseDirectory(
234+
normalized,
235+
[&](const std::string& name)
236+
{
237+
std::string ext = getExtension(name);
238+
239+
if (ext == ".lua" || ext == ".luau")
240+
files.push_back(name);
241+
}
242+
);
243+
}
244+
else
245+
{
246+
files.push_back(normalized);
247+
}
248+
}
249+
250+
251+
return files;
252+
}
253+
254+
int typecheck(const std::vector<std::string>& sourceFilesInput)
215255
{
216256
// Lute only supports the new type solver
217257
FFlag::LuauSolverV2.value = true;
218258

259+
std::vector<std::string> sourceFiles = processSourceFiles(sourceFilesInput);
260+
261+
if (sourceFiles.empty())
262+
{
263+
fprintf(stderr, "Error: lute --check expects a file to type check.\n\n");
264+
return 1;
265+
}
266+
219267
Luau::Mode mode = Luau::Mode::Strict;
220268
bool annotate = true;
221269
std::string basePath = "";

cli/tc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
#include "Luau/Frontend.h"
55
#include "Luau/FileUtils.h"
66

7-
int typecheck(const std::vector<std::string> sourceFiles);
7+
int typecheck(const std::vector<std::string>& sourceFiles);

0 commit comments

Comments
 (0)