OILS / cpp / run.sh View on Github | oilshell.org

54 lines, 16 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./run.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10boilerplate() {
11 local rel_name=${1:-osh/bool_stat}
12 local ns=$(basename $rel_name) # bool_stat
13
14 local name="$(echo $rel_name | tr / _)"
15
16 local prefix="cpp/$name" # cpp/core_bool_stat
17 echo $prefix
18
19 local guard="$(echo $rel_name | tr a-z/ A-Z_)_H"
20 echo $guard
21
22 cat > $prefix.h <<EOF
23// $name.h
24
25#ifndef $guard
26#define $guard
27
28namespace $ns {
29
30} // namespace $ns
31
32#endif // $guard
33
34EOF
35
36 cat > $prefix.cc <<EOF
37// $name.cc
38
39#include "$name.h"
40
41namespace $ns {
42
43// TODO: fill in
44
45} // namespace $ns
46EOF
47
48 ls -l $prefix.{h,cc}
49 echo Wrote $prefix.{h,cc}
50
51
52}
53
54"$@"