11#! /bin/bash -e
22
3- # shellcheck source=.settings
4- . " ${BASH_SOURCE%/* } /.settings"
5-
6- if [ " $# " -ne 0 ] || \
7- [ ! -f CMakeLists.txt ] || \
8- [ -e equipment ] || \
9- [ -e internals ] || \
10- [ -e provides ] || \
11- [ -e requires ] ; then
12- CMD=" ${0##*/ } "
13- cat << EOF
14- Usage: $CMD
15-
16- Creates an example "Hello, world!" program in a freshly initialized project
17- directory.
18- EOF
19- exit 1
20- fi
21-
22- mkdir -p provides/include/message_v1
3+ # shellcheck source=init
4+ . " ${BASH_SOURCE%/* } /init"
235
24- cat << EOF > provides/include/message_v1/hello.hpp
6+ add-file provides/include/message_v1/hello.hpp << EOF
257#include <string>
268
279namespace message_v1 {
@@ -31,25 +13,21 @@ std::string hello(const std::string &to);
3113}
3214EOF
3315
34- mkdir -p provides/library
35-
36- cat << EOF > provides/library/hello.cpp
16+ add-file provides/library/hello.cpp << EOF
3717#include "message_v1/hello.hpp"
3818
3919std::string message_v1::hello(const std::string &to) {
4020 return "Hello, " + to + "!";
4121}
4222EOF
4323
44- cat << EOF > provides/CMakeLists.txt
24+ add-file provides/CMakeLists.txt << EOF
4525add_conventional_library(message_v1)
4626EOF
4727
4828" $CPPSM /commands/add" equipment https://github.com/per-framework/testing.cpp.git v1
4929
50- mkdir -p internals/testing
51-
52- cat << EOF > internals/testing/message_test.cpp
30+ add-file internals/testing/message_test.cpp << EOF
5331#include "message_v1/hello.hpp"
5432
5533#include "testing_v1/test.hpp"
@@ -60,9 +38,7 @@ auto hello_test =
6038 test([]() { verify("Hello, there!" == message_v1::hello("there")); });
6139EOF
6240
63- mkdir -p internals/program
64-
65- cat << EOF > internals/program/hello.cpp
41+ add-file internals/program/hello.cpp << EOF
6642#include "message_v1/hello.hpp"
6743
6844#include <iostream>
@@ -73,11 +49,9 @@ int main() {
7349}
7450EOF
7551
76- cat << EOF > internals/CMakeLists.txt
52+ add-file internals/CMakeLists.txt << EOF
7753add_conventional_executable_tests(PRIVATE message_v1 testing_v1)
7854
7955add_conventional_executable(hello)
8056target_link_libraries(hello PRIVATE message_v1)
8157EOF
82-
83- git add internals provides
0 commit comments