]> git.rmz.io Git - dotfiles.git/blob - bin/mkcomponent
nvim: provide wrappers to lazy.core.util.{error,warn,info}
[dotfiles.git] / bin / mkcomponent
1 #!/bin/bash
2
3 version="0.1"
4
5 function usage()
6 {
7 echo "Usage : $0 [options]
8
9 Create a header/source/test triplet.
10
11 Options:
12 -h,--help Display this message
13 -v,--version Display script version"
14 }
15
16 # Parse arguments
17 declare -a args
18 while [[ $# -gt 0 ]]; do
19 opt="$1"
20
21 case $opt in
22 -h|--help) usage; exit 0 ;;
23 -v|--version) echo "$0 -- Version $version"; exit 0 ;;
24 -*)
25 echo -e "\n Option does not exist : $opt\n"
26 usage; exit 1 ;;
27
28 *) args+=("$opt"); shift ;;
29 esac
30 done
31
32 read -d '' fpp_copy <<EOD
33 // Copyright © Focal Point Positioning Limited $(date +%Y). All Rights Reserved.
34 // This code is the copyright of Focal Point Positioning Limited and
35 // cannot be used, copied or distributed without the express written
36 // permission of Focal Point Positioning Limited.
37 EOD
38
39 _h=${COMPONENT_HEADER_SUFFIX:-.hpp}
40 _c=${COMPONENT_SOURCE_SUFFIX:-.cpp}
41 _t=${COMPONENT_TEST_SUFFIX:-.t.cpp}
42
43 for f in "${args[@]}"; do
44 c=$(basename $f)
45 printf '%s\n\n#pragma once\n\n' "$fpp_copy" >$f$_h
46 printf '%s\n\n#include "%s"\n\n' "$fpp_copy" "$c$_h" >$f$_c
47 printf '%s\n\n#include <gtest/gtest.h>\n\n#include "%s"\n' "$fpp_copy" "$c$_h" >$f$_t
48 done