@@ -115,6 +115,7 @@ bool ContextImp::initialize(const char* proc_name, const Json &cfg, Module *modu
115115{
116116 TBOX_ASSERT (module != nullptr );
117117 module_ = module ;
118+ js_conf_ = &cfg;
118119
119120 if (util::json::HasObjectField (cfg, " loop" )) {
120121 auto &js_loop = cfg[" loop" ];
@@ -344,8 +345,9 @@ void ContextImp::initShell()
344345 util::string::Replace (txt, " \n " , " \r\n " );
345346 s.send (txt);
346347 (void )args;
347- }
348- , " print Loop's stat data" );
348+ },
349+ " print Loop's stat data"
350+ );
349351 wp_nodes->mountNode (loop_stat_node, loop_stat_print_node, " print" );
350352
351353 auto loop_stat_reset_node = wp_nodes->createFuncNode (
@@ -355,8 +357,9 @@ void ContextImp::initShell()
355357 ss << " done\r\n " ;
356358 s.send (ss.str ());
357359 (void )args;
358- }
359- , " reset Loop's stat data" );
360+ },
361+ " reset Loop's stat data"
362+ );
360363 wp_nodes->mountNode (loop_stat_node, loop_stat_reset_node, " reset" );
361364
362365 {
@@ -365,8 +368,9 @@ void ContextImp::initShell()
365368 s.send (ToString (running_time ()));
366369 s.send (" \r\n " );
367370 (void )args;
368- }
369- , " Print running times" );
371+ },
372+ " Print running times"
373+ );
370374 wp_nodes->mountNode (ctx_node, func_node, " running_time" );
371375 }
372376 }
@@ -387,8 +391,9 @@ void ContextImp::initShell()
387391
388392 s.send (ss.str ());
389393 (void )args;
390- }
391- , " Print start time point" );
394+ },
395+ " Print start time point"
396+ );
392397 wp_nodes->mountNode (ctx_node, func_node, " start_time" );
393398 }
394399
@@ -414,8 +419,9 @@ void ContextImp::initShell()
414419 oss << " undo_task_peak_num: " << snapshot.undo_task_peak_num << " \r\n " ;
415420 s.send (oss.str ());
416421 (void )args;
417- }
418- , " Print thread pool's snapshot" );
422+ },
423+ " Print thread pool's snapshot"
424+ );
419425 wp_nodes->mountNode (threadpool_node, func_node, " snapshot" );
420426 }
421427 }
@@ -433,8 +439,9 @@ void ContextImp::initShell()
433439 ss << ' v' << major << ' .' << minor << ' .' << rev << ' _' << build << " \r\n " ;
434440 s.send (ss.str ());
435441 (void )args;
436- }
437- , " Print app version" );
442+ },
443+ " Print app version"
444+ );
438445 wp_nodes->mountNode (info_node, func_node, " app_ver" );
439446 }
440447 {
@@ -446,8 +453,9 @@ void ContextImp::initShell()
446453 ss << ' v' << major << ' .' << minor << ' .' << rev << " \r\n " ;
447454 s.send (ss.str ());
448455 (void )args;
449- }
450- , " Print tbox version" );
456+ },
457+ " Print tbox version"
458+ );
451459 wp_nodes->mountNode (info_node, func_node, " tbox_ver" );
452460 }
453461 {
@@ -457,8 +465,9 @@ void ContextImp::initShell()
457465 ss << GetAppBuildTime () << " \r\n " ;
458466 s.send (ss.str ());
459467 (void )args;
460- }
461- , " Print buildtime" );
468+ },
469+ " Print buildtime"
470+ );
462471 wp_nodes->mountNode (info_node, func_node, " build_time" );
463472 }
464473 {
@@ -468,27 +477,34 @@ void ContextImp::initShell()
468477 ss << GetAppDescribe () << " \r\n " ;
469478 s.send (ss.str ());
470479 (void )args;
471- }
472- , " Print app describe" );
480+ },
481+ " Print app describe"
482+ );
473483 wp_nodes->mountNode (info_node, func_node, " what" );
474484 }
475485 }
476486
477487 {
478- auto apps_node = wp_nodes->createDirNode (" Applications directory" );
479- wp_nodes->mountNode (wp_nodes->rootNode (), apps_node, " apps" );
480-
488+ auto dump_node = wp_nodes->createDirNode (" dump directory" );
489+ wp_nodes->mountNode (wp_nodes->rootNode (), dump_node, " dump" );
481490 auto func_node = wp_nodes->createFuncNode (
482- [this ] (const Session &s, const Args &) {
491+ [this ] (const Session &s, const Args &a ) {
483492 Json js;
484- module_->toJson (js);
493+ if (util::string::IsEndWith (a[0 ], " apps" )) {
494+ module_->toJson (js);
495+ } else if (util::string::IsEndWith (a[0 ], " conf" )){
496+ js = *js_conf_;
497+ }
485498 auto json_str = js.dump (2 );
486499 util::string::Replace (json_str, " \n " , " \r\n " );
487500 s.send (json_str);
488501 s.send (" \r\n " );
489- }
490- , " Dump apps as JSON" );
491- wp_nodes->mountNode (apps_node, func_node, " dump" );
502+ },
503+ " Dump as JSON"
504+ );
505+
506+ wp_nodes->mountNode (dump_node, func_node, " apps" );
507+ wp_nodes->mountNode (dump_node, func_node, " conf" );
492508 }
493509}
494510
0 commit comments