Skip to content

Commit

Permalink
update: can handle command with &&
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuwynu23 committed Apr 5, 2024
1 parent 3f91156 commit 7e23f6f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion bin/.autofile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
::ASYNC
####################### This is a comment ############################
+ notepad
+ echo Hello World > test.txt && cat test.txt
######################################################################


Binary file modified bin/auto.exe
Binary file not shown.
28 changes: 9 additions & 19 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
# constants variable
#constants variable
BIN=bin/auto.exe


# icon resource
ICO=resources/icon.rc
RES=resources/resource.res

# source files
SRC=$(wildcard src/*.cpp)

# compiling source files
# compiling source file
all: compile_icon compile_source

# running executable
run: $(BIN)
run:
$(BIN)

compile_source:
c++ -std=c++11 $(RES) -o $(BIN) -I include $(SRC)

# compiling source files
compile_source: $(BIN)

$(BIN): $(SRC)
c++ $(CXXFLAGS) $(LDFLAGS) $(RES) -o $@ $^

# compiling icon resource
compile_icon: $(RES)
compile_icon:
windres $(ICO) -O coff -o $(RES)

$(RES): $(ICO)
windres $^ -O coff -o $@

# cleaning executable
clean:
del $(BIN) $(RES)
del $(BIN)
15 changes: 9 additions & 6 deletions src/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start \"" + tp + "\" cmd /K " + tp;
string command = "start \"" + tp + "\" cmd /K " + "\" " + tp + "\"";
__termExecuteAsync(command);
}
else if (executionType == 0)
Expand All @@ -106,7 +106,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start \"" + tp + "\" cmd /K " + tp;
string command = "start \"" + tp + "\" cmd /K " + "\" " + tp + "\"";
__termExecuteSync(command);
}
}
Expand All @@ -120,7 +120,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start /MIN \"" + tp + "\" cmd /K " + tp;
string command = "start /MIN \"" + tp + "\" cmd /K " + "\" " + tp + "\"";
__termExecuteAsync(command);
}
else if (executionType == 0)
Expand All @@ -130,7 +130,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start /MIN \"" + tp + "\" cmd /K " + tp;
string command = "start /MIN \"" + tp + "\" cmd /K " + "\" " + tp + "\"";
__termExecuteSync(command);
}
}
Expand All @@ -143,7 +143,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start /MIN \"" + tp + "\" cmd /C " + tp;
string command = "start /B \"" + tp + "\" cmd /C " + "\" " + tp + "\"";
__termExecuteAsync(command);
}
else if (executionType == 0)
Expand All @@ -153,7 +153,7 @@ void __readStringLine(std::string fileName)
// remove the first character
tp = tp.erase(0, 1);
// execute the command with start -
string command = "start /MIN \"" + tp + "\" cmd /C " + tp;
string command = "start /B \"" + tp + "\" cmd /C " + "\" " + tp + "\"";
__termExecuteSync(command);
}
}
Expand All @@ -167,6 +167,9 @@ void __readStringLine(std::string fileName)
}
cout << "\n End:\n " << endl;
newfile.close();

// clear screen
system("cls");
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
* All rights reserved.
*/
#include "lib.h"

int main(int, char const **argv)
{
// if argv[1] is null then set sourceFile to default '.autofile'
std::string sourceFile = ".autofile";
std::string SOURCE_FILE = ".autofile";

if (argv[1] != NULL)
{
sourceFile = argv[1];
SOURCE_FILE = argv[1];
}
autoRunner(sourceFile);
autoRunner(SOURCE_FILE);

return 0;
}

0 comments on commit 7e23f6f

Please sign in to comment.