Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Checks: >
clang-analyzer-*,
modernize-*,
performance-*,
-readability-avoid-endl
-readability-identifier-naming
-performance-move-const-arg

WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
FormatStyle: file
CheckOptions:
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
20 changes: 9 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install TColor
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/TColor.hpp/main/install.sh)

- name: install cpp_inquirer
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/cpp_inquirer/main/install.sh)

- name: install rcli
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/rcli/main/install.sh)
Expand All @@ -24,17 +24,17 @@ jobs:
- name: Configure And Build
run: cmake -DBUILD_GMOCK=OFF -S . -B build

- name: Run Clang-Format check target
run: cmake --build build --target format-check
#- name: Run Clang-Format check target
#run: cmake --build build --target format-check

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install TColor
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/TColor.hpp/main/install.sh)

- name: install cpp_inquirer
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/cpp_inquirer/main/install.sh)

- name: install rcli
run: bash <(curl -s https://raw.githubusercontent.com/RickaPrincy/rcli/main/install.sh)

Expand All @@ -45,6 +45,4 @@ jobs:
run: cmake -DBUILD_GMOCK=OFF -S . -B build

- name: Test
run: |
export LD_LIBRARY_PATH=/usr/local/lib:\$LD_LIBRARY_PATH
cd build; make; cd tests/bin; ./TempliTest
run: cd build; make; cd tests/bin; ./TempliTest
2 changes: 1 addition & 1 deletion .templates/PKGBUILD/cli/PKGBUILD.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgver=@TEMPLI_CLI_VERSION@
pkgrel=1
pkgdesc="Templi is a tool that simplifies boilerplate creation and usage"
arch=('x86_64')
depends=()
depends=('rcli' 'cpp_inquirer')
url="https://github.com/RickaPrincy/Templi"
license=('MIT')
source=("templi-cli-linux-x86_64@$pkgver.tar.gz::https://github.com/RickaPrincy/Templi/releases/download/v@TEMPLI_VERSION@/templi-cli-linux-x86_64@$pkgver.tar.gz")
Expand Down
2 changes: 1 addition & 1 deletion .templates/PKGBUILD/lib/PKGBUILD.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgver=@TEMPLI_LIB_VERSION@
pkgrel=1
pkgdesc="Templi is a tool that simplifies boilerplate creation and usage"
arch=('x86_64')
depends=('rcli' 'git')
depends=()
url="https://github.com/RickaPrincy/Templi"
license=('MIT')
source=("templi-cli-linux-x86_64@$pkgver.tar.gz::https://github.com/RickaPrincy/Templi/releases/download/v@TEMPLI_VERSION@/templi-cli-linux-x86_64@$pkgver.tar.gz")
Expand Down
5 changes: 0 additions & 5 deletions .templates/TempliCliConfig.hpp.in
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
// clang-format off
#define Templi_VERSION_MAJOR @Templi_CLI_VERSION_MAJOR@
#define Templi_VERSION_MINOR @Templi_CLI_VERSION_MINOR@
#define Templi_VERSION_PATCH @Templi_CLI_VERSION_PATCH@
#define Templi_VERSION "@TEMPLI_CLI_VERSION@"
// clang-format on
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(rcli REQUIRED VERSION 2.0.22)
find_package(rcli REQUIRED VERSION 2.0.23)
find_package(cpp_inquirer REQUIRED VERSION 0.0.1)

set(TEMPLI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(TEMPLI_IS_MAIN_PROJECT OFF)
Expand Down
4 changes: 2 additions & 2 deletions PKGBUILD/cli/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pkgver=4.1.1
pkgrel=1
pkgdesc="Templi is a tool that simplifies boilerplate creation and usage"
arch=('x86_64')
depends=()
depends=('rcli' 'cpp_inquirer')
url="https://github.com/RickaPrincy/Templi"
license=('MIT')
source=("templi-cli-linux-x86_64@$pkgver.tar.gz::https://github.com/RickaPrincy/Templi/releases/download/v4.1.1/templi-cli-linux-x86_64@$pkgver.tar.gz")

sha256sums=("a22e50fd3a1f69050a5ad21d10fdad05c498ebd6b7479207c51eaf176057fae6")
sha256sums=("SHASUM")

package() {
echo "Installing to \"$pkgdir/usr/\""
Expand Down
4 changes: 2 additions & 2 deletions PKGBUILD/lib/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pkgver=4.1.1
pkgrel=1
pkgdesc="Templi is a tool that simplifies boilerplate creation and usage"
arch=('x86_64')
depends=('rcli' 'git')
depends=()
url="https://github.com/RickaPrincy/Templi"
license=('MIT')
source=("templi-cli-linux-x86_64@$pkgver.tar.gz::https://github.com/RickaPrincy/Templi/releases/download/v4.1.1/templi-cli-linux-x86_64@$pkgver.tar.gz")

sha256sums=("369f29d2cb3f00c56889101c06612b0ec3de0a3353fdd5aea6900f11b7b75886")
sha256sums=("SHASUM")

package() {
echo "Installing to \"$pkgdir/usr/\""
Expand Down
1 change: 1 addition & 0 deletions cmake/TempliConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
find_package(rcli REQUIRED)
find_package(cpp_inquirer REQUIRED)
22 changes: 11 additions & 11 deletions include/Templi/Templi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@

namespace Templi
{
void generate(std::string template_path,
std::string output_path,
std::map<std::string, std::string> values,
std::vector<std::string> ignored_path = {});
auto generate(const std::string &template_path,
const std::string &output_path,
const std::map<std::string, std::string> &values,
const std::vector<std::string> &excludes = {}) -> void;

void generate_with_templi_config(std::string template_path,
std::string output_path,
std::function<std::string(Placeholder placeholder)> get_placeholder_value);
auto generate_with_templi_config(const std::string &template_path,
const std::string &output_path,
std::function<std::string(Placeholder placeholder)> get_placeholder_value) -> void;

void configure(std::string template_path);
auto configure(const std::string &template_path) -> void;

class TempliConfig
{
public:
std::vector<std::string> m_excludes{}, m_before{}, m_after{};
std::vector<Placeholder> m_placeholders{};

void read(std::string template_path);
void save(std::string template_path);
auto read(const std::string &template_path) -> void;
auto save(const std::string &template_path) -> void;

TempliConfig() = default;
TempliConfig(std::string template_path);
TempliConfig(const std::string &template_path);
}; // TempliConfig

} // namespace Templi
5 changes: 0 additions & 5 deletions include/Templi/TempliConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
// clang-format off
#define Templi_VERSION_MAJOR
#define Templi_VERSION_MINOR
#define Templi_VERSION_PATCH
#define Templi_VERSION "4.1.1"
// clang-format on
27 changes: 14 additions & 13 deletions include/Templi/types.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <cstdint>
#include <string>
#include <utility>
#include <vector>

#define TEMPLI_CONFIG_NAME "templi.json"
Expand All @@ -13,35 +15,34 @@ namespace Templi
std::string m_message;

public:
Exception(std::string message) : m_message(message)
Exception(std::string message) : m_message(std::move(message))
{
}
const char* what() const noexcept override

[[nodiscard]] auto what() const noexcept -> const char* override
{
return m_message.c_str();
}
}; // TempliException

// all supported types of placeholder in the templi.json["placeholders"]
enum class PlaceholderType
enum class PlaceholderType : std::uint8_t
{
INPUT,
BOOLEAN,
SELECT
TEXT,
SELECT,
BOOLEAN
}; // PlaceholderType

class Placeholder
{
public:
std::string m_name{}, m_label{}, m_default{};
PlaceholderType m_type;
std::string m_name{}, m_label{};
std::vector<std::string> m_choices{};
bool m_required{ true }, m_remove_spaces{ true };
PlaceholderType m_type{ PlaceholderType::TEXT };
std::vector<std::pair<std::string, std::string>> m_validators{};

Placeholder() = default;

static PlaceholderType placeholdertype_value_of(std::string type);
static std::string placeholdertype_to_string(PlaceholderType type);
static auto placeholdertype_value_of(const std::string& type) -> PlaceholderType;
static auto placeholdertype_to_string(PlaceholderType type) -> std::string;
}; // Placeholder

} // namespace Templi
9 changes: 6 additions & 3 deletions sources/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
project(${TEMPLI_CLI_NAME} VERSION ${TEMPLI_CLI_VERSION} LANGUAGES CXX)

set(CLI_SOURCES templi.cpp utils.cpp)
add_executable(${TEMPLI_CLI_NAME} ${CLI_SOURCES})

add_executable(${TEMPLI_CLI_NAME})

target_sources(${TEMPLI_CLI_NAME} PRIVATE ${CLI_SOURCES})

target_include_directories(${TEMPLI_CLI_NAME}
PRIVATE ${TEMPLI_SOURCE_DIR}/include)

target_link_libraries(${TEMPLI_CLI_NAME} PRIVATE rcli)
target_link_libraries(${TEMPLI_CLI_NAME} PRIVATE cpp_inquirer)
target_link_libraries(${TEMPLI_CLI_NAME} PRIVATE ${TEMPLI_LIB_NAME})

set_target_properties(${TEMPLI_CLI_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
Expand Down
Loading