mirror of
https://github.com/lucaspalomodevelop/autom.git
synced 2026-03-12 23:27:21 +00:00
Merge pull request #8 from lucaspalomodevelop/7-show-content-of-scriptfile-with-show-command
7 show content of scriptfile with show command
This commit is contained in:
commit
d150ee9b7c
29
.github/workflows/c-cpp.yml
vendored
29
.github/workflows/c-cpp.yml
vendored
@ -1,29 +0,0 @@
|
||||
name: C/C++ CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main", "dev" ]
|
||||
pull_request:
|
||||
branches: [ "main", "dev" ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
# - name: configure
|
||||
# run: ./configure
|
||||
- name: make
|
||||
run: make
|
||||
# - name: make check
|
||||
# run: make check
|
||||
# - name: make distcheck
|
||||
# run: make distcheck
|
||||
22
src/main.cpp
22
src/main.cpp
@ -26,6 +26,7 @@ void input(int argc, char *argv[])
|
||||
command.addCommand("new", "[script] - Adds a script", addScript);
|
||||
command.addCommand("edit", "[script] - Edits a script", editScript);
|
||||
command.addCommand("remove", "[script] - Remove a script", removeScript);
|
||||
command.addCommand("show", "[script] - Shows a script", showScript);
|
||||
command.addDefaultCommand(runScript);
|
||||
command.runCommand(argv[1], argc, argv);
|
||||
}
|
||||
@ -41,6 +42,27 @@ void runScript(int argc, char *argv[])
|
||||
system(script.c_str());
|
||||
}
|
||||
|
||||
void showScript(int argc, char *argv[])
|
||||
{
|
||||
std::string script = dir + "/" + argv[1];
|
||||
if (std::filesystem::exists(script))
|
||||
{
|
||||
std::cout << "Showing script: " << argv[1] << std::endl;
|
||||
std::ifstream file(script);
|
||||
std::string line;
|
||||
int line_number = 0;
|
||||
while (getline(file, line))
|
||||
{
|
||||
line_number++;
|
||||
std::cout << line_number << " "<< line << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Script " << argv[1] << " does not exist" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// list all scripts in the autom directory
|
||||
void listScripts(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@ -33,6 +33,8 @@ void editScript(int argc, char *argv[]);
|
||||
void editScript(std::string name);
|
||||
// remove a script in the autom directory
|
||||
void removeScript(int argc, char *argv[]);
|
||||
// show a script in the autom directory
|
||||
void showScript(int argc, char *argv[]);
|
||||
// help function for showing help message
|
||||
void help(int argc, char *argv[]);
|
||||
// void create(int argc,char *argv[]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user