ecode: Added "convert-lang-path" CLI command, to convert a JSON syntax definition to CPP code (it's just a helper to help me to migrate languages definitions from other editors).

Added Crystal and V languages syntax highlighting.
This commit is contained in:
Martín Lucas Golini
2023-02-25 18:54:11 -03:00
parent 98db130868
commit ea6450bd3b
3 changed files with 210 additions and 1 deletions
+20
View File
@@ -3352,6 +3352,10 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
"Comma separated language names to export its language definitions. \"export-lang-path\" "
"must be defined. Retrieved with \"--health\" command.",
{ "export-lang" }, "" );
args::ValueFlag<std::string> convertLangPath(
parser, "convert-lang-path",
"Convert any JSON language definition to CPP syntax definition (development helper)",
{ "convert-lang-path" }, "" );
try {
auto args = Sys::parseArguments( argc, argv );
@@ -3378,6 +3382,22 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
return EXIT_FAILURE;
}
if ( convertLangPath && !convertLangPath.Get().empty() ) {
Sys::windowAttachConsole();
IOStreamFile sfile( convertLangPath.Get() );
if ( sfile.isOpen() ) {
std::vector<std::string> adedLangs;
if ( SyntaxDefinitionManager::instance()->loadFromStream( sfile, &adedLangs ) ) {
for ( const auto& lang : adedLangs ) {
const auto& def =
SyntaxDefinitionManager::instance()->getByLanguageName( lang );
std::cout << SyntaxDefinitionManager::toCPP( def ) << "\n";
}
}
}
return EXIT_SUCCESS;
}
if ( exportLangPath && !exportLangPath.Get().empty() ) {
Sys::windowAttachConsole();
exportLanguages( exportLangPath.Get(), exportLang.Get() );