From 9031a2350d8a805d8e9eba040186b048fe90231f Mon Sep 17 00:00:00 2001 From: Lucas Palomo Develop Date: Tue, 16 May 2023 19:08:57 +0200 Subject: [PATCH 1/3] Create cmake.yml --- .github/workflows/cmake.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..cf8e1ce --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,37 @@ +name: CMake + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} + From dd8eec55647e361a69b2648daae661fa2b77659a Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Tue, 16 May 2023 20:12:00 +0200 Subject: [PATCH 2/3] delete .github folder --- .github/workflows/c-cpp.yml | 29 ----------------------------- .github/workflows/cmake.yml | 37 ------------------------------------- 2 files changed, 66 deletions(-) delete mode 100644 .github/workflows/c-cpp.yml delete mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml deleted file mode 100644 index 852909d..0000000 --- a/.github/workflows/c-cpp.yml +++ /dev/null @@ -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 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml deleted file mode 100644 index cf8e1ce..0000000 --- a/.github/workflows/cmake.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: CMake - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. - # You can convert this to a matrix build if you need cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build - # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Test - working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C ${{env.BUILD_TYPE}} - From 8a1d70479dfd7c503b5168f6b8e0ff1a18502693 Mon Sep 17 00:00:00 2001 From: lucaspalomodevelop Date: Thu, 8 Jun 2023 21:05:30 +0200 Subject: [PATCH 3/3] add show command --- src/main.cpp | 22 ++++++++++++++++++++++ src/main.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 548a5a2..df693e2 100644 --- a/src/main.cpp +++ b/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[]) { diff --git a/src/main.h b/src/main.h index 9c6f034..18cbf38 100644 --- a/src/main.h +++ b/src/main.h @@ -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[]);