Skip to content

Commit c8df2b3

Browse files
committed
Implement initial shell script template
1 parent 74932e3 commit c8df2b3

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

copier.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ _envops:
1111
variable_end_string: "}}"
1212
variable_start_string: "{{"
1313

14+
_tasks:
15+
- "chmod +x {{script_name}}.sh"
16+
1417
# TEMPLATE QUESTIONS
15-
project_name:
18+
script:
1619
type: str
17-
help: >-
18-
What's your project name?
19-
20-
Do not use dots or spaces in the name; just "A-Za-z0-9-_" please.
20+
help: What is your new shell script name?
2121

22-
name:
23-
type: str
24-
help: What is the name to greet for the generator hello world example?
22+
nix:
23+
type: bool
24+
help: Do you want to use nix-sell (shebang header)?
25+
default: yes
2526

2627
# TEMPLATE NONE-CONFIGURABLE DEFAULTS
27-
package_name:
28+
script_name:
2829
type: str
29-
default: "{{ project_name|lower|replace(' ','_')|replace('-','_') }}"
30-
when: false
30+
default: "{{ script|lower|replace(' ','_')|replace('-','_') }}"
31+
when: false

template/{{package_name}}/hello_world.py.jinja

Lines changed: 0 additions & 2 deletions
This file was deleted.

template/{{script_name}}.sh.jinja

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{%- if nix -%}
2+
#! /usr/bin/env nix-shell
3+
#! nix-shell -p coreutils -i bash
4+
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-22.05.tar.gz
5+
{%- else -%}
6+
#!/usr/bin/env bash
7+
{% endif %}
8+
9+
if [ -n "$DEBUG" ]; then
10+
set -x
11+
fi
12+
13+
set -o errexit
14+
set -o nounset
15+
set -o pipefail
16+
17+
echo "Hello world!"
18+

0 commit comments

Comments
 (0)