summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-20 03:06:55 +0000
committerBo Ørsted Andresen <bo.andresen@zlin.dk>2007-03-20 03:06:55 +0000
commitf194af93b8119654dd75434ca6db746bffe2a739 (patch)
tree554faada239530890baae0dab6b5cf1f7306dc1b
parent69aeb5e269ee0d7c9dffb11489899b7011d46e1c (diff)
downloadwgetpaste-f194af93b8119654dd75434ca6db746bffe2a739.tar.gz
Major reordering of service definitions and functions.
-rwxr-xr-xwgetpaste118
1 files changed, 55 insertions, 63 deletions
diff --git a/wgetpaste b/wgetpaste
index cd8c5bd..fe0ea3b 100755
--- a/wgetpaste
+++ b/wgetpaste
@@ -47,6 +47,33 @@ show_url() {
INFO_COMMAND="emerge --info"
INFO_ARGS="--ignore-default-opts"
+SERVICES=(ca rafb osl sh)
+SERVICE_URLS=(http://pastebin.ca http://rafb.net/paste/ http://pastebin.osuosl.org/ http://sh.nu/p/)
+SERVICE_URLS_RAW=(http://pastebin.ca http://rafb.net/paste/paste.php http://pastebin.osuosl.org/pastebin.php http://sh.nu/p/)
+# 4 (base indentation) + max service length + 2 (space + dash)
+INDENTATION=10
+# languages
+rafb_LANGUAGES=(C C89 C99 C++ C\# Java Pascal Perl PHP PL\/I Python Ruby SQL VB Plain_Text)
+ca_LANGUAGES=(Plain_Text Asterisk_Configuration C C++ PHP Perl Java VB C\# Ruby Python Pascal \
+mIRC PL/I XML SQL Scheme ActionScript Ada Apache_Configuration Assembly_\(NASM\) ASP Bash CSS \
+Delphi HTML_4\.0_Strict JavaScript LISP Lua Microprocessor_ASM Objective_C VB\.NET)
+osl_LANGUAGES=(Plain_Text ActionScript Ada Apache_Log_File AppleScript Assembly_\(NASM\) \
+ASP Bash C C_for_Macs CAD_DCL CAD_Lisp C++ C\# ColdFusion CSS D Delphi Diff DOS Eiffel Fortran \
+FreeBasic Game_Maker HTML_4\.0_Strict INI_file Java Javascript Lisp Lua MatLab Microprocessor_ASM \
+MySQL NullSoft_Installer Objective_C OCaml Openoffice\.org_BASIC Oracle_8 Pascal Perl PHP Python \
+QBasic Robots\.txt Ruby Scheme Smarty SQL TCL VB VB\.NET VisualFoxPro XML)
+osl_LANGUAGE_VALUES=(text actionscript ada apache applescript asm asp bash c c_mac caddcl \
+cadlisp cpp csharp cfm css d delphi diff dos eiffel fortran freebasic gml html4strict ini java \
+javascript lisp lua matlab mpasm mysql nsis objc ocaml oobas oracle8 pascal perl php python \
+qbasic robots ruby scheme smarty sql tcl vb vbnet visualfoxpro xml)
+# expirations
+ca_EXPIRATIONS=(Never 5_minutes 10_minutes 15_minutes 30_minutes 45_minutes 1_hour 2_hours 4_hours \
+8_hours 12_hours 1_day 2_days 3_days 1_week 2_weeks 3_weeks 1_month 2_months 3_months 4_months \
+5_months 6_months 1_year)
+osl_EXPIRATIONS=(Never 1_day 1_month)
+osl_EXPIRATION_VALUES=(f d m)
+
+
### defaults
# The following defaults can be overridden in either /etc/wgetpaste or ~/.wgetpaste.
@@ -100,31 +127,11 @@ show_usage() {
### services
-SERVICES=(ca rafb osl sh)
-SERVICE_URLS=(http://pastebin.ca http://rafb.net/paste/ http://pastebin.osuosl.org/ http://sh.nu/p/)
-SERVICE_URLS_RAW=(http://pastebin.ca http://rafb.net/paste/paste.php http://pastebin.osuosl.org/pastebin.php http://sh.nu/p/)
-# 4 (base indentation) + max service length + 2 (space + dash)
-INDENTATION=10
-
header() {
[[ "${1}" == "Service" ]] || BY="by $(get_recipient) "
echo "${1}s supported ${BY}(case sensitive):"
}
-show_services() {
- header "Service"
- for ((i=0; i<${#SERVICES[*]}; i++)); do
- echo " ${SERVICES[i]} "$'\e'"[${INDENTATION}G- ${SERVICE_URLS[i]}"
- done
-}
-
-verify_service() {
- for service in ${SERVICES[*]}; do
- [[ "$*" == "${service}" ]] && return 0
- done
- fail "$*" "service" "show_services"
-}
-
show() {
for var in $(eval "echo \${${SERVICE}_${1}[*]}"); do
echo " ${var//_/ }"
@@ -148,24 +155,12 @@ verify() {
return 1
}
-### languages
-
-# rafb
-rafb_LANGUAGES=(C C89 C99 C++ C\# Java Pascal Perl PHP PL\/I Python Ruby SQL VB Plain_Text)
-# ca - ordering is important here as count is used as value
-ca_LANGUAGES=(Plain_Text Asterisk_Configuration C C++ PHP Perl Java VB C\# Ruby Python Pascal \
-mIRC PL/I XML SQL Scheme ActionScript Ada Apache_Configuration Assembly_\(NASM\) ASP Bash CSS \
-Delphi HTML_4\.0_Strict JavaScript LISP Lua Microprocessor_ASM Objective_C VB\.NET)
-# osl - ordering for languages and values must be the same
-osl_LANGUAGES=(Plain_Text ActionScript Ada Apache_Log_File AppleScript Assembly_\(NASM\) \
-ASP Bash C C_for_Macs CAD_DCL CAD_Lisp C++ C\# ColdFusion CSS D Delphi Diff DOS Eiffel Fortran \
-FreeBasic Game_Maker HTML_4\.0_Strict INI_file Java Javascript Lisp Lua MatLab Microprocessor_ASM \
-MySQL NullSoft_Installer Objective_C OCaml Openoffice\.org_BASIC Oracle_8 Pascal Perl PHP Python \
-QBasic Robots\.txt Ruby Scheme Smarty SQL TCL VB VB\.NET VisualFoxPro XML)
-osl_LANGUAGE_VALUES=(text actionscript ada apache applescript asm asp bash c c_mac caddcl \
-cadlisp cpp csharp cfm css d delphi diff dos eiffel fortran freebasic gml html4strict ini java \
-javascript lisp lua matlab mpasm mysql nsis objc ocaml oobas oracle8 pascal perl php python \
-qbasic robots ruby scheme smarty sql tcl vb vbnet visualfoxpro xml)
+show_services() {
+ header "Service"
+ for ((i=0; i<${#SERVICES[*]}; i++)); do
+ echo " ${SERVICES[i]} "$'\e'"[${INDENTATION}G- ${SERVICE_URLS[i]}"
+ done
+}
show_languages() {
header "Language"
@@ -178,48 +173,45 @@ show_languages() {
esac
}
-# this is in place because rafb.net (probably others too) rejects any paste with an invalid language
-verify_language() {
+show_expiration_options() {
+ header "Expiration option"
case "${SERVICE}" in
- ca )
- verify LANGUAGE count && return 0
+ ca | osl )
+ show EXPIRATIONS
;;
rafb )
- verify LANGUAGE && return 0
- ;;
- osl )
- verify LANGUAGE value && return 0
+ no_support expiration "Pastes on $(get_recipient) expire after 24 hours.\n"
;;
* )
- [[ ${LANGUAGE_SET} ]] || return 0
+ no_support expiration
;;
esac
- fail "${LANGUAGE}" "language" "show_languages"
}
-### expiration
-
-# ca
-ca_EXPIRATIONS=(Never 5_minutes 10_minutes 15_minutes 30_minutes 45_minutes 1_hour 2_hours 4_hours \
-8_hours 12_hours 1_day 2_days 3_days 1_week 2_weeks 3_weeks 1_month 2_months 3_months 4_months \
-5_months 6_months 1_year)
-# osl - ordering for options and values must be the same
-osl_EXPIRATIONS=(Never 1_day 1_month)
-osl_EXPIRATION_VALUES=(f d m)
+verify_service() {
+ for service in ${SERVICES[*]}; do
+ [[ "$*" == "${service}" ]] && return 0
+ done
+ fail "$*" "service" "show_services"
+}
-show_expiration_options() {
- header "Expiration option"
+# this is in place because rafb.net (probably others too) rejects any paste with an invalid language
+verify_language() {
case "${SERVICE}" in
- ca | osl )
- show EXPIRATIONS
+ ca )
+ verify LANGUAGE count && return 0
;;
rafb )
- no_support expiration "Pastes on $(get_recipient) expire after 24 hours.\n"
+ verify LANGUAGE && return 0
+ ;;
+ osl )
+ verify LANGUAGE value && return 0
;;
* )
- no_support expiration
+ [[ ${LANGUAGE_SET} ]] || return 0
;;
esac
+ fail "${LANGUAGE}" "language" "show_languages"
}
verify_expiration_options() {