This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
new_draft.sh
executable file
·106 lines (73 loc) · 1.57 KB
/
new_draft.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
HELP="
New draft script help
---------------------
There are 3 parameters:
1. date <YYYY-MM-DD>
2. issue <NUMBER>
3. author <AUTHOR>
EXAMPLE:
--------
For issue #100, on Jan 4, 2018, by jsq
Run: $0 2018-01-04 100 jsq
"
if [ "$#" -ne 3 ]; then
echo "$HELP"
exit 1
fi
if [[ ! ($1 =~ ^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$) ]]; then
echo "💥 ERROR: param 1, <DATE>, should be valid date format YYYY-MM-DD. Found '$1'"
echo "$HELP"
exit 1
fi
if [[ ! ($2 =~ ^[0-9]+$) ]]; then
echo "💥 ERROR: param 2, <ISSUE>, should be an integer. Found '$2'"
echo "$HELP"
exit 1
fi
if [[ ! ($3 =~ ^[A-Za-z]+$) ]]; then
echo "💥 ERROR: param 3, <AUTHOR>, should be alphabetic. Found '$3'"
echo "Find valid author options in _data/authors.yml"
echo "$HELP"
exit 1
fi
ISSUE="_drafts/$1-issue-$2.md"
mkdir -p "_drafts"
touch $ISSUE
echo "---
layout: post
title: ! 'Issue #$2'
author: $3
sponsor:
<!-- fill-in sponsor info or remove -->
link: TODO
heading: TODO
body: TODO
displaylink: TODO
---
> TODO: intro comments
<!--excerpt-->
{% include sponsor.html %}
### Starter tasks
> TODO
### Swift Unwrapped
> TODO: Latest episode(s) of Swift Unwrapped
### News and community
> TODO
### Commits and pull requests
> TODO
### Accepted proposals
> TODO
### Returned proposals
> TODO
### Rejected proposals
> TODO
### Proposals in review
> TODO
### Swift Forums
> TODO
### Finally
> TODO: something funny/fun. tweet, link, etc." > $ISSUE
echo "Successfully created '$ISSUE' written by '$3'"
echo "Opening..."
open $ISSUE