add edit-config action

This commit is contained in:
James Tomasino 2018-03-06 16:44:31 -05:00
parent 6ba34bf60f
commit 09472ab21a
3 changed files with 26 additions and 1 deletions

View File

@ -44,6 +44,7 @@ burrow phlog # create new phlog post
burrow recipe # add or update a recipe to box burrow recipe # add or update a recipe to box
burrow topic # add or update a topic file burrow topic # add or update a topic file
burrow create-config # generate a default config file burrow create-config # generate a default config file
burrow edit-config # open your config file for editing
burrow update-git # pull latest git repo for gopher dir, if exists burrow update-git # pull latest git repo for gopher dir, if exists
``` ```
@ -53,6 +54,8 @@ listed below and provide an easy way to customize your configuration. At a
minimum you should update your `config_dir_gopher` to point to the folder on minimum you should update your `config_dir_gopher` to point to the folder on
your local computer where your gopher hole resides. your local computer where your gopher hole resides.
- `edit-config` will open your burrow configuration file for easy editing.
- `phlog` will prompt for the title of a new post, then open it in your default - `phlog` will prompt for the title of a new post, then open it in your default
`$EDITOR`. By default it will provide you a template, but you can override this `$EDITOR`. By default it will provide you a template, but you can override this
by including a `.template` file in your phlog directory. by including a `.template` file in your phlog directory.

21
burrow
View File

@ -40,6 +40,7 @@ arg_recipe=0
arg_phlog=0 arg_phlog=0
arg_topic=0 arg_topic=0
arg_create_config=0 arg_create_config=0
arg_edit_config=0
arg_update_git=0 arg_update_git=0
# silence directory movements # silence directory movements
@ -60,6 +61,7 @@ COMMANDS:
recipe Add new recipe to box recipe Add new recipe to box
topic Add or update a topic topic Add or update a topic
create-config Create a default configuration file create-config Create a default configuration file
edit-config Edit your configuration file
update-git Silently pulls gopher git repo if it exists update-git Silently pulls gopher git repo if it exists
OPTIONAL FLAGS: OPTIONAL FLAGS:
@ -126,6 +128,7 @@ function parse_input {
"recipe") arg_recipe=1 ;; "recipe") arg_recipe=1 ;;
"topic") arg_topic=1 ;; "topic") arg_topic=1 ;;
"create-config") arg_create_config=1 ;; "create-config") arg_create_config=1 ;;
"edit-config") arg_edit_config=1 ;;
"update-git") arg_update_git=1 ;; "update-git") arg_update_git=1 ;;
*) echo "Unknown command: $arg";; *) echo "Unknown command: $arg";;
esac esac
@ -336,6 +339,18 @@ function make_post {
fi fi
} }
function edit_config {
if [[ -f "$HOME/.config/burrow/config" ]]; then
$EDITOR "$HOME/.config/burrow/config"
elif [[ -f "$HOME/.config/burrow" ]]; then
$EDITOR "$HOME/.config/burrow"
elif [[ -f "$HOME/.burrow" ]]; then
$EDITOR "$HOME/.burrow"
else
die "No configuration found" 0
fi
}
function create_config { function create_config {
if [[ ! -f "$HOME/.config/burrow/config" ]] && \ if [[ ! -f "$HOME/.config/burrow/config" ]] && \
[[ ! -f "$HOME/.config/burrow" ]] && \ [[ ! -f "$HOME/.config/burrow" ]] && \
@ -386,7 +401,7 @@ function main {
parse_input "$@" parse_input "$@"
if [[ $arg_shortlist -gt 0 ]]; then if [[ $arg_shortlist -gt 0 ]]; then
out="phlog topic recipe create-config update-git -v -h -d" out="phlog topic recipe edit-config create-config update-git -v -h -d"
# include long options only if using gnu getopt # include long options only if using gnu getopt
getopt -T > /dev/null getopt -T > /dev/null
if [ $? -eq 4 ]; then if [ $? -eq 4 ]; then
@ -411,6 +426,10 @@ function main {
create_config create_config
fi fi
if [[ $arg_edit_config -gt 0 ]]; then
edit_config
fi
for configfile in $configfiles; do for configfile in $configfiles; do
if [[ -f $configfile ]]; then if [[ -f $configfile ]]; then
source "$configfile" source "$configfile"

View File

@ -22,6 +22,9 @@ Generates a default configuration file at
if no other configuration file exists. It is populated with the default if no other configuration file exists. It is populated with the default
settings. settings.
.TP .TP
.B edit-config
Opens your burrow configuration file for editing if it exists.
.TP
.B update-git .B update-git
If the gopher directory resides within a git repository, this action will do a If the gopher directory resides within a git repository, this action will do a
silent silent