@@ -225,6 +225,7 @@ static void display_help(std::ostream & out) {
225
225
std::cout << " --json report Lean output (e.g., messages) as JSON (one per line)\n " ;
226
226
std::cout << " -E --error=kind report Lean messages of kind as errors\n " ;
227
227
std::cout << " --deps just print dependencies of a Lean input\n " ;
228
+ std::cout << " --src-deps just print dependency sources of a Lean input\n " ;
228
229
std::cout << " --print-prefix print the installation prefix for Lean and exit\n " ;
229
230
std::cout << " --print-libdir print the installation directory for Lean's built-in libraries and exit\n " ;
230
231
std::cout << " --profile display elaboration/type checking time for each definition/theorem\n " ;
@@ -235,6 +236,7 @@ static void display_help(std::ostream & out) {
235
236
std::cout << " -D name=value set a configuration option (see set_option command)\n " ;
236
237
}
237
238
239
+ static int only_src_deps = 0 ;
238
240
static int print_prefix = 0 ;
239
241
static int print_libdir = 0 ;
240
242
static int json_output = 0 ;
@@ -255,6 +257,7 @@ static struct option g_long_options[] = {
255
257
{" stats" , no_argument, 0 , ' a' },
256
258
{" quiet" , no_argument, 0 , ' q' },
257
259
{" deps" , no_argument, 0 , ' d' },
260
+ {" src-deps" , no_argument, &only_src_deps, 1 },
258
261
{" deps-json" , no_argument, 0 , ' J' },
259
262
{" timeout" , optional_argument, 0 , ' T' },
260
263
{" c" , optional_argument, 0 , ' c' },
@@ -399,6 +402,12 @@ void print_imports(std::string const & input, std::string const & fname) {
399
402
consume_io_result (lean_print_imports (mk_string (input), mk_option_some (mk_string (fname)), io_mk_world ()));
400
403
}
401
404
405
+ /* def printImportSrcs (input : String) (fileName : Option String := none) : IO Unit */
406
+ extern " C" object* lean_print_import_srcs (object* input, object* file_name, object* w);
407
+ void print_import_srcs (std::string const & input, std::string const & fname) {
408
+ consume_io_result (lean_print_import_srcs (mk_string (input), mk_option_some (mk_string (fname)), io_mk_world ()));
409
+ }
410
+
402
411
/* def printImportsJson (fileNames : Array String) : IO Unit */
403
412
extern " C" object* lean_print_imports_json (object * file_names, object * w);
404
413
void print_imports_json (array_ref<string_ref> const & fnames) {
@@ -697,6 +706,11 @@ extern "C" LEAN_EXPORT int lean_main(int argc, char ** argv) {
697
706
return 0 ;
698
707
}
699
708
709
+ if (only_src_deps) {
710
+ print_import_srcs (contents, mod_fn);
711
+ return 0 ;
712
+ }
713
+
700
714
// Quick and dirty `#lang` support
701
715
// TODO: make it extensible, and add `lean4md`
702
716
if (contents.compare (0 , 5 , " #lang" ) == 0 ) {
0 commit comments