Skip to content

Commit fce65e9

Browse files
Updating interactive tutorial for better clarity and fixing typos
1 parent 1a85505 commit fce65e9

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

Examples/InteractiveTutorial.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -597,33 +597,7 @@ void CallHello();
597597
WriteFile("tutorial/Hello.hpp", fileContent);
598598
}
599599

600-
DELAYED_OUTPUT("Turns out I still need to edit tutorial/main.cpp to call the function.");
601-
DELAYED_OUTPUT("Let me do that now.");
602-
DELAYED_OUTPUT("Press enter to continue...");
603-
GetInput(true);
604-
605-
{
606-
std::string fileContent = ReadFile("tutorial/main.cpp");
607-
if(fileContent.empty())
608-
{
609-
ssLOG_ERROR("Failed to read tutorial/main.cpp");
610-
return false;
611-
}
612-
613-
size_t returnPos = fileContent.find("return 0;");
614-
if(returnPos == std::string::npos)
615-
{
616-
ssLOG_ERROR("Failed to find return 0; in tutorial/main.cpp");
617-
return false;
618-
}
619-
fileContent.replace(returnPos,
620-
std::string("return 0;").size(),
621-
"CallHello();\n return 0;");
622-
623-
WriteFile("tutorial/main.cpp", std::string("#include \"Hello.hpp\"\n") + fileContent);
624-
}
625-
626-
DELAYED_OUTPUT("Now let me add the second C++ file to `OtherFilesToBeCompiled` in the YAML file.");
600+
DELAYED_OUTPUT("Now let me add the second C++ file to `SourceFiles` in the tutorial/main.yaml file.");
627601
DELAYED_OUTPUT("Press enter to continue...");
628602
GetInput(true);
629603

@@ -632,15 +606,15 @@ void CallHello();
632606
DefaultPlatform:
633607
DefaultProfile: ["WORLD=42"]
634608
635-
OtherFilesToBeCompiled:
609+
SourceFiles:
636610
DefaultPlatform:
637611
DefaultProfile: ["./Hello.cpp"]
638612
)";
639613

640614
WriteFile("tutorial/main.yaml", yamlContent);
641615
}
642616

643-
DELAYED_OUTPUT("The path to the other file is always **relative to the script file**.");
617+
DELAYED_OUTPUT("The paths to the files are always __relative to the script file__.");
644618
DELAYED_OUTPUT("You can also add include paths for the script to the `IncludePaths` field");
645619
DELAYED_OUTPUT("Although unnecessary in this case, let me add \"./\" to the include paths.");
646620
DELAYED_OUTPUT("Press enter to continue...");
@@ -651,7 +625,7 @@ void CallHello();
651625
DefaultPlatform:
652626
DefaultProfile: ["WORLD=42"]
653627
654-
OtherFilesToBeCompiled:
628+
SourceFiles:
655629
DefaultPlatform:
656630
DefaultProfile: ["./Hello.cpp"]
657631
@@ -663,17 +637,43 @@ void CallHello();
663637
WriteFile("tutorial/main.yaml", yamlContent);
664638
}
665639

640+
DELAYED_OUTPUT("Turns out, I still need to edit tutorial/main.cpp to call the function.");
641+
DELAYED_OUTPUT("Let me do that now.");
642+
DELAYED_OUTPUT("Press enter to continue...");
643+
GetInput(true);
644+
645+
{
646+
std::string fileContent = ReadFile("tutorial/main.cpp");
647+
if(fileContent.empty())
648+
{
649+
ssLOG_ERROR("Failed to read tutorial/main.cpp");
650+
return false;
651+
}
652+
653+
size_t returnPos = fileContent.find("return 0;");
654+
if(returnPos == std::string::npos)
655+
{
656+
ssLOG_ERROR("Failed to find return 0; in tutorial/main.cpp");
657+
return false;
658+
}
659+
fileContent.replace(returnPos,
660+
std::string("return 0;").size(),
661+
"CallHello();\n return 0;");
662+
663+
WriteFile("tutorial/main.cpp", std::string("#include \"Hello.hpp\"\n") + fileContent);
664+
}
665+
666666
DELAYED_OUTPUT("Let's run the script again.");
667667
if(!RunCommandWithPrompt("cd tutorial && " + runcpp2ExecutablePath + " main.cpp"))
668668
return false;
669669

670670
DELAYED_OUTPUT("You should see the output `Hello from another C++ file`.");
671671
DELAYED_OUTPUT("");
672672

673-
DELAYED_OUTPUT( "If you **only** have a setting that applies to all platforms and profiles like "
673+
DELAYED_OUTPUT( "If you **ONLY** have a setting that applies to all platforms and profiles like "
674674
"what we have,");
675675
DELAYED_OUTPUT("you can specify the settings directly.");
676-
DELAYED_OUTPUT("Let me update the YAML file and show you what I mean.");
676+
DELAYED_OUTPUT("Let me update the tutorial/main.yaml file and show you what I mean.");
677677
DELAYED_OUTPUT("Press enter to continue...");
678678
GetInput(true);
679679

@@ -799,7 +799,7 @@ bool Chapter3_ExternalDependencies()
799799
DELAYED_OUTPUT("Press enter to continue...");
800800
GetInput(true);
801801

802-
DELAYED_OUTPUT("A dependency must contain a \"Source\" to determine where it is.");
802+
DELAYED_OUTPUT("A dependency must contain a \"Source\" to determine where it is from.");
803803
DELAYED_OUTPUT("In this case, it is coming from a \"Git\" repository.");
804804
DELAYED_OUTPUT( "If you have a git submodule, you can point it to a local directory with "
805805
"\"Local\" instead of \"Git\"");
@@ -808,7 +808,7 @@ bool Chapter3_ExternalDependencies()
808808

809809
DELAYED_OUTPUT( "Next, you have \"LibraryType\" which tells runcpp2 what type of dependency "
810810
"this is. Other options include \"Static\", \"Object\" and \"Shared\"");
811-
DELAYED_OUTPUT("That's pretty much it for a header only library. Let's run it shell we?");
811+
DELAYED_OUTPUT("That's pretty much it for a header only library. Let's run it shall we?");
812812
if(!RunCommandWithPrompt("cd tutorial && " + runcpp2ExecutablePath + " Logging.cpp"))
813813
return false;
814814

@@ -998,7 +998,7 @@ bool Chapter3_ExternalDependencies()
998998
return false;
999999
}
10001000

1001-
DELAYED_OUTPUT("I have extracted the SDL2 dependency block to a standalone YAML file.");
1001+
DELAYED_OUTPUT("I have extracted the SDL2 dependency block to tutorial/SDL2.yaml file.");
10021002
DELAYED_OUTPUT("Press enter to continue...");
10031003
GetInput(true);
10041004

0 commit comments

Comments
 (0)