Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master quill by Jaka Kranjc (da92703b2c66561d98bba1af7124c8ef091bda79)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT mail.sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master quill by Jaka Kranjc (da92703b2c66561d98bba1af7124c8ef091bda79)
  • Date: Sat, 20 Jan 2007 10:10:27 -0600

GIT changes to master quill by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

usr/bin/quill | 64
+++++++++++++++++++++------------------
var/lib/quill/ChangeLog | 8 ++++
var/lib/quill/modules/libcore | 17 ++++++++--
var/lib/quill/modules/libhistory | 4 +-
4 files changed, 60 insertions(+), 33 deletions(-)

New commits:
commit da92703b2c66561d98bba1af7124c8ef091bda79
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

* quill: improved the parameter parsing and added two shortcuts
(getopts?)
removed redundant message, codex_does_spell_exsist prints its own
* libcore: added check_parameter to check for missing parameters
added shorthand combo examples to quill_help
fixed quill_purge move syntax error
* libhistory: don't use hardcoded tabs, so the function is easier to
reuse

diff --git a/usr/bin/quill b/usr/bin/quill
index b89b742..2897fdb 100755
--- a/usr/bin/quill
+++ b/usr/bin/quill
@@ -50,36 +50,46 @@ QUILL_TMP_DIR=~/.sourcemage/tmp
#---
## Not really a function it's supposed to parse the command line parameters
#---
-while [ -n "$1" ]; do
- if echo "" $1 | grep -q "^ -"; then
+while [[ -n $1 ]]; do
+ if grep -q "^ -" <<< " $1"; then
case $1 in
--fmxml|-f)
- [[ -z $2 ]] &&
- message "${PROBLEM_COLOR}Missing parameter$DEFAULT_COLOR"
&&
- quill_help 101
- export QUILL_FMXML_MODE="on"; export QUILL_TARGET="$2"
- shift 2 ;;
+ check_parameter $2
+ QUILL_FMXML_MODE="on"
+ shift ;;
--perlcpan|-c)
- [[ -z $2 ]] &&
- message "${PROBLEM_COLOR}Missing parameter$DEFAULT_COLOR"
&&
- quill_help 101
- export QUILL_CPAN_MODE="on"; export QUILL_TARGET="$2"
- shift 2 ;;
- --purge|-p) export QUILL_MODE="purge"; quill_purge $2 ;;
- --update|-u) export QUILL_UPDATE="on" QUILL_TARGET="$2"; shift 2 ;;
- --apprentice|-a) export QUILL_MODE="apprentice"; shift 1 ;;
- --mage|-m) export QUILL_MODE="mage"; shift 1 ;;
- --wizard|-w) export QUILL_MODE="wizard"; shift 1 ;;
---reconfigure|-r) export QUILL_MODE="reconfigure"; shift 1 ;;
+ check_parameter $2
+ QUILL_CPAN_MODE="on"
+ shift ;;
+ --update|-u)
+ check_parameter $2
+ QUILL_UPDATE="on"
+ shift ;;
+ -uf|-fu)
+ check_parameter $2
+ QUILL_UPDATE="on"
+ QUILL_FMXML_MODE="on"
+ shift ;;
+ -uc|-cu)
+ check_parameter $2
+ QUILL_UPDATE="on"
+ QUILL_CPAN_MODE="on"
+ shift ;;
+ --purge|-p) QUILL_MODE="purge"; quill_purge $2 ;;
+ --apprentice|-a) QUILL_MODE="apprentice" ;;
+ --mage|-m) QUILL_MODE="mage" ;;
+ --wizard|-w) QUILL_MODE="wizard" ;;
+--reconfigure|-r) QUILL_MODE="reconfigure" ;;
--help|-h) quill_help ;;
--version|-v) quill_version ;;
*) message "${PROBLEM_COLOR}Invalid parameter
$1$DEFAULT_COLOR"
- quill_help 102;;
+ quill_help 102 ;;
esac
- else
- shift
fi
+ shift
done
+export QUILL_MODE QUILL_FMXML_MODE QUILL_CPAN_MODE QUILL_TARGET
+
unset -f message
. /etc/sorcery/config
EDITOR=${EDITOR:-nano}
@@ -92,7 +102,7 @@ quill_rc

# we should do some quillrc sanity checking someday
[[ ! -d $QUILL_SPELL_DIR ]] &&
- echo "PEBKAC: bad QUILL_SPELL_DIR ($QUILL_SPELL_DIR)" &&
+ echo "Bad QUILL_SPELL_DIR ($QUILL_SPELL_DIR)!" &&
echo "Try running quill -r" &&
exit 7

@@ -129,11 +139,8 @@ fi
if [[ "$QUILL_UPDATE" == "on" ]]
then
SPELL_NAME=$QUILL_TARGET
- if ! codex_does_spell_exist $SPELL_NAME
- then
- message "${PROBLEM_COLOR}$SPELL_NAME is not a spell!$DEFAULT_COLOR"
- exit 6
- fi
+ codex_does_spell_exist $SPELL_NAME || exit 6
+
while true; do
actions=('Update the spell to a newer version' \
'Manage patches' \
@@ -144,7 +151,7 @@ then
'Try it out' \
'Quit' )
echo
- query_list "What do you want to do?" ANSWER "${actions[6]}"
"${actions[@]}"
+ query_list "What do you want to do?" ANSWER "Quit" "${actions[@]}"

[[ $ANSWER == "Quit" ]] && exit 0

@@ -225,6 +232,7 @@ then
get_sources_and_urls
echo

+ message "Summoning ..."
#download; we are not a grimoire so some hacking is needed
# also workaround sorcery bug #13412
to_summon="$sources_and_urls"
diff --git a/var/lib/quill/ChangeLog b/var/lib/quill/ChangeLog
index 287a514..43dbb53 100644
--- a/var/lib/quill/ChangeLog
+++ b/var/lib/quill/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-20 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * quill: improved the parameter parsing and added two shortcuts
(getopts?)
+ removed redundant message, codex_does_spell_exsist prints its own
+ * libcore: added check_parameter to check for missing parameters
+ added shorthand combo examples to quill_help
+ fixed quill_purge move syntax error
+ * libhistory: don't use hardcoded tabs, so the function is easier to
reuse
+
2007-01-18 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* quill: moved purging to libcore
* libcore: made quill_purge run a safe quill_rc
diff --git a/var/lib/quill/modules/libcore b/var/lib/quill/modules/libcore
index 00cf977..1acd00a 100644
--- a/var/lib/quill/modules/libcore
+++ b/var/lib/quill/modules/libcore
@@ -244,7 +244,7 @@ function quill_purge() {
else
message "${PROBLEM_COLOR}failed!$DEFAULT_COLOR"
fi
- exit $rc ;;
+ exit $rc
}

#---
@@ -263,7 +263,6 @@ function dump_default_function() {
#---
function quill_version() {

-
message "quill - $QUILL_VERSION
Copyright (C) 2006 Source Mage
This is free software. You may redistribute copies of it under the terms of
@@ -284,13 +283,22 @@ Arjan 'abouter' Bouter
exit 0
}

+#---
+## @Synopsis checks if the parameter is missing
+## @Synopsis if not, saves it in QUILL_TARGET
+#---
+function check_parameter() {
+ [[ -z $1 ]] &&
+ message "${PROBLEM_COLOR}Missing parameter$DEFAULT_COLOR" &&
+ quill_help 101 ||
+ QUILL_TARGET="$1"
+}

#---
## @Synopsis function that displays help and exits
#---
function quill_help() {

-
message "quill -$QUILL_VERSION
Copyright (C) 2006 Source Mage
This is free software. You may redistribute copies of it under the terms of
@@ -318,6 +326,9 @@ EXAMPLES:

Update a spell; try to get some information from Perl-CPAN:
quill -c wormux -u wormux
+
+ The same can be done with shorter forms (fu, uf, cu and uc are supported):
+ quill -cu wormux
"
exit ${1:-0}
}
diff --git a/var/lib/quill/modules/libhistory
b/var/lib/quill/modules/libhistory
index b8c3e46..f6b98fc 100644
--- a/var/lib/quill/modules/libhistory
+++ b/var/lib/quill/modules/libhistory
@@ -24,9 +24,9 @@ function add_history_entry()

if grep -q "$title" HISTORY;
then
- sed -i "/$title/ a\ * $1" HISTORY
+ sed -i "/$title/ a\\\t* $1" HISTORY
else # first time
- sed -i "1 s/^.*$/$title\n * $1\n\n&/" HISTORY
+ sed -i "1 s/^.*$/$title\n\t* $1\n\n&/" HISTORY
fi
}




  • [SM-Commit] GIT changes to master quill by Jaka Kranjc (da92703b2c66561d98bba1af7124c8ef091bda79), Jaka Kranjc, 01/20/2007

Archive powered by MHonArc 2.6.24.

Top of Page