Added '--config off' and '--config none' to disable config files at launch

This commit is contained in:
Dylan 2016-01-30 12:05:53 +11:00
parent f86b796a5c
commit c99d472ebb
3 changed files with 27 additions and 11 deletions

3
1.1.md
View File

@ -13,7 +13,8 @@
- Fetch now has a config file that you can share with people and<br \>
keep between script versions!
- Added `--config` and `$config_file` to specify a custom config location.
- Added `$config` to enable / disable config files
- Added `--config off`, `--config none` and `$config` to enable / disable config files<br \>
at launch or in script.
### Info

View File

@ -184,7 +184,7 @@ alias fetch2="fetch \
## Usage
usage: ${0##*/} --option "value" --option
usage: ${0##*/} --option "value"
Info:
--osx_buildversion Hide/Show Mac OS X build version.
@ -257,9 +257,9 @@ alias fetch2="fetch \
Ascii:
--ascii Where to get the ascii from, Possible values:
'distro', '/path/to/ascii'
distro, /path/to/ascii
--ascii_color Color to print the ascii art
--ascii_distro distro Which Distro's ascii art to print
--ascii_distro distro Which Distro\'s ascii art to print
Screenshot:
@ -269,6 +269,8 @@ alias fetch2="fetch \
--scrot_cmd Screenshot program to launch
Other:
--config Specify a path to a custom config file
--config none Launch the script without a config file
--help Print this text and exit

27
fetch
View File

@ -1744,6 +1744,7 @@ getscriptdir () {
# Check for $config_file first
getconfig () {
# Check $config_file
if [ -f "$config_file" ]; then
source "$config_file"
return
@ -1768,6 +1769,14 @@ getconfig () {
fi
}
# Check the commandline flags early for '--config none/off'
case "$@" in
*"--config off"* | *'--config "off"'* | *"--config 'off'"* | \
*"--config none"* | *'--config "none"'* | *"--config 'none'"*)
config="off"
;;
esac
# If config files are enabled
[ "$config" == "on" ] && getconfig
@ -1868,6 +1877,8 @@ usage () { cat << EOF
--scrot_cmd Screenshot program to launch
Other:
--config Specify a path to a custom config file
--config none Launch the script without a config file
--help Print this text and exit
EOF
@ -1926,9 +1937,7 @@ while [ "$1" ]; do
[ -z "$2" ] && image="ascii"
case "$2" in
"--"*)
image="ascii"
;;
"--"*) image="ascii" ;;
esac
;;
@ -1949,9 +1958,7 @@ while [ "$1" ]; do
[ -z "$2" ] && ascii="distro"
case "$2" in
"--"*)
ascii="distro"
;;
"--"*) ascii="distro" ;;
esac
;;
@ -1964,7 +1971,13 @@ while [ "$1" ]; do
--scrot_cmd) scrot_cmd="$2" ;;
# Other
--config) config_file="$2"; getconfig ;;
--config)
case "$2" in
"none" | "off") config="off" ;;
*) config_file="$2"; config="on"; getconfig ;;
esac
;;
--help) usage ;;
esac