~bpv/sbs

e0512cfe2dadec6200332d7b2e450e2c0751ecfe — Bryce Vandegrift 5 months ago aa520ed
Added rename feature and v1.0.1
2 files changed, 13 insertions(+), 2 deletions(-)

M README.md
M sbs
M README.md => README.md +1 -0
@@ 36,6 36,7 @@ sbs can also be used on a directory by directory basis, just change the
sbs new		# Create a new blog post
sbs edit	# Quickly edit existing draft
sbs publish	# Publish a draft and turn it into a webpage
sbs rename	# Rename a draft
sbs delete	# Delete a draft
sbs help	# Show quick help
sbs version	# Show version

M sbs => sbs +12 -2
@@ 33,7 33,7 @@ new() {
	read -rp "Enter file name: " name
	echo $name | grep -q "\"" && echo "Double quotes are not allowed in file names." && exit 1
	name="$(echo $name | tr -d '[:punct:]' | tr ' ' '-' | tr '[:upper:]' '[:lower:]')"
	( [ -f "$draft_dir/$name.md" ] || [ -f "$blog_dir/$name.html" ] ) && echo "A draft or post already exists under that name!" && exit 1
	( [ -f "$draft_dir/$name.md" ] || [ -f "$blog_dir/$name/$name.html" ] ) && echo "A draft or post already exists under that name!" && exit 1
	$EDITOR "$draft_dir/$name.md"
}



@@ 60,6 60,14 @@ publish() {
	rm -f $draft_dir/$choice
}

rename() {
	listDrafts rename "$@"
	read -rp "Enter new file name: " name
	name="$(echo $name | tr -d '[:punct:]' | tr ' ' '-' | tr '[:upper:]' '[:lower:]')"
	( [ -f "$draft_dir/$name.md" ] || [ -f "$blog_dir/$name/$name.html" ] ) && echo "A draft or post already exists under that name!" && exit 1
	mv "$draft_dir/$choice" "$draft_dir/$name.md"
}

delete() {
	listDrafts delete "$@"
	rm "$draft_dir/$choice"


@@ 73,6 81,7 @@ Operations:
        sbs new
        sbs edit
        sbs publish
	sbs rename
        sbs delete
        sbs help
        sbs version


@@ 82,7 91,7 @@ EOF
}

version() {
	echo "sbs: Static Blogging System V1.0.0"
	echo "sbs: Static Blogging System V1.0.1"
}

[ -z "$EDITOR" ] && EDITOR="vi"


@@ 91,6 100,7 @@ case "$1" in
	new) shift;	new "$@" ;;
	edit) shift;	edit "$@" ;;
	publish) shift;		publish "$@" ;;
	rename) shift;		rename "$@" ;;
	delete|del) shift;	delete "$@" ;;
	help|-h)	help ;;
	version|-v)	version ;;