Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options for install script #87

Closed
sjthespian opened this issue Apr 6, 2016 · 4 comments
Closed

Options for install script #87

sjthespian opened this issue Apr 6, 2016 · 4 comments

Comments

@sjthespian
Copy link

I found that it would be really nice to have a way to pass options to dotbot via. the install script. For example, most of the time I don't want the chatty version of dotbot, I just want to know if things failed. I'm torn over whether or not being able to override the config suffix and basedir makes any sense, but it was easy enough to add so I left it in the code for now.

Here is the version of the script I am using (along with the change elsewhere in your Issues to allow for multiple config files).

#!/usr/bin/env bash

set -e

DEFAULT_CONFIG_PREFIX="default"
CONFIG_SUFFIX=".conf.yaml"
DOTBOT_DIR="dotbot"

DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Parse command line options
DOTBOTOPTS=""
VERBOSE=""
while getopts "Qqvd:c:" opt; do
    case $opt in
    v|Q|q)
        VERBOSE=$opt
        DOTBOTOPTS="$DOTBOTOPTS -$opt"
        ;;
    d)
        BASEDIR=$opt
        ;;
    c)
        CONFIG_SUFFIX=$opt
        ;;
    ?)
        exit 1
        ;;
    esac
done
# Clean up parsed options
while (( $((OPTIND--)) > 1 )); do
    shift
done

cd "${BASEDIR}"
git submodule update --init --recursive "${DOTBOT_DIR}"

for conf in ${DEFAULT_CONFIG_PREFIX} ${@}; do
    if [ $VERBOSE != "Q" ]; then
        echo -e "\nInstalling $conf..."
    fi
    "${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" ${DOTBOTOPTS} -d "${BASEDIR}" -c "${conf}${CONFIG_SUFFIX}"
done
@anishathalye
Copy link
Owner

The install script already allows this. That's what the "${@}" does on line 14:

"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}"

You can try it - do ./install -q and see what happens.

@sjthespian
Copy link
Author

Unless you use the multi-config version of the script, then that gets parsed in the 'for conf' loop. My change above adds parsing of the non-config file options.

@anishathalye
Copy link
Owner

Ah, I see. The wiki might be a good place to put this. The current documentation on this is here: https://github.com/anishathalye/dotbot/wiki/Tips-and-Tricks

@anishathalye
Copy link
Owner

Mention of this issue added to wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants