Skip to content

Commit

Permalink
update: added special block(any block start with .)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuwynu23 committed Dec 21, 2024
1 parent cfc0b73 commit 5571a92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions bin/.autofile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
::ASYNC

.init{
+ echo "Hello Initial"
}
dev {
+ echo Hello World > test.txt && cat test.txt
}
Expand Down
Binary file modified bin/auto.exe
Binary file not shown.
10 changes: 5 additions & 5 deletions src/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void __processBlocks(std::string fileName, std::string targetBlock)
currentBlock = line.substr(0, line.length() - 2); // Extract block name (before '{')
std::cout << "Found block: " << currentBlock << std::endl;

// Check if this is the target block
if (currentBlock == targetBlock)
// Check if this is the target block or if the block starts with "."
if (currentBlock == targetBlock || currentBlock.front() == '.')
{
blockFound = true; // Set the flag if the block matches the target
}
Expand All @@ -140,9 +140,9 @@ void __processBlocks(std::string fileName, std::string targetBlock)
// End of current block
currentBlock = "";
}
else if (!currentBlock.empty() && currentBlock == targetBlock)
else if (!currentBlock.empty() && (currentBlock == targetBlock || currentBlock.front() == '.'))
{
// If we are in the target block, process commands
// If we are in the target block or a special block starting with a dot (".")
if (line[0] == '+')
{
// Process commands within a block
Expand Down Expand Up @@ -220,4 +220,4 @@ void __processBlocks(std::string fileName, std::string targetBlock)
void autoRunner(std::string sourceFile, std::string targetBlock)
{
__processBlocks(sourceFile, targetBlock);
}
}

0 comments on commit 5571a92

Please sign in to comment.