summary refs log tree commit diff stats
path: root/new/post
blob: 48e4549cd9496414d850193eda471fa66789b2b5 (plain)
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
#!/bin/sh

usage() {
	cat >&2 <<EOF
$0:	make a new post
Usage:	$0 [OPTIONS...] [TITLE...]
Options:
 -h	Show this help and exit
 -n	Don't edit the post
 -F FILE
	Instead of using TITLE as the post's title, use it as a filename to read
	into the post.
Parameters:
 TITLE...
	The title of the post (its first line)
EOF
}

main() {
	startoff='--message="$*"'
	edit='--edit'
	while getopts hF:n OPT
	do
		case "$OPT" in
			(h) usage 0 ;;
			(F) startoff='--file="$*"' ;;
			(n) edit='--no-edit' ;;
			(*) usage 1 ;;
		esac
	done
	shift $((OPTIND - 1))

	git add .
	eval git commit --allow-empty --no-status $startoff $edit
}

main "$@"