Skip to Content.
Sympa Menu

sm-sorcery-bugs - [SM-Sorcery-Bugs] [Bug 6392] New: Improved API for query and store config information

sm-sorcery-bugs AT lists.ibiblio.org

Subject: Bugs for Sorcery are reported here

List archive

Chronological Thread  
  • From: bugzilla-daemon AT metalab.unc.edu
  • To: sm-sorcery-bugs AT lists.ibiblio.org
  • Subject: [SM-Sorcery-Bugs] [Bug 6392] New: Improved API for query and store config information
  • Date: Thu, 18 Mar 2004 12:59:11 -0500

http://bugs.sourcemage.org/show_bug.cgi?id=6392

Summary: Improved API for query and store config information
Product: Sorcery
Version: Feature Request
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P3
Component: subroutines
AssignedTo: sm-sorcery-bugs AT lists.ibiblio.org
ReportedBy: marek AT printsoft.cz


While writing my first spell, I found query system insufficient.

I put something work into it, and this is resulting new API, prepared for your
criticism (and appreciation, ofcourse :) )

Input methods:
-------------

query, query_string, query_list

* query
- will stay without any change:
query QUESTION DEFAULT
return 0 - yes, 1 - no

* query_string
query_string VARIABLE QUESTION DEFAULT
return 0 - user replied, 1 - default value

* query_list
- former select_list
- renamed, because it will match query* convention
- it's used only on one place afaik, so change should be trivial
- added timeout
- added question
query_list VARIABLE QUESTION OPTION1 OPTION2 OPTION3 ...
return 0 - user selected, 1 - default value


Config methods:
--------------

Usable mainly for manipulating $SPELL_CONFIG file during CONFIGURE

config_set_option, config_get_option
config_query, config_query_string, config_query_list

* config_set_option
- only echo "$OPTION_NAME=$STRING" >> $SPELL_CONFIG
config_set_option OPTION_NAME STRING

* config_get_option
config_get_option OPTION_NAME VARIABLE(optional)
return 0 - option is presented in file, 1 - it's not there

Example:
config_get_option ROOT TEMP_ROOT
retrieves line "^ROOT=blablabla" and puts TEMP_ROOT="blablabla"

* config_query
config_query OPTION_NAME QUESTION DEFAULT
return 0 - option entered from user, 1 - option read from config
function asks user only if the option is not allready set in $SPELL_CONFIG
function also sets OPTION_NAME='y' or 'n' depending on the answer

* config_query_string
config_query_string OPTION_NAME QUESTION DEFAULT
return 0 - option entered from user, 1 - option read from config, or default
function asks user only if the option is not allready set in $SPELL_CONFIG
function also sets OPTION_NAME=answer supplied

* config_query_list
config_query_list OPTION_NAME QUESTION O1 O2 O3 ...
return 0 - option entered from user, 1 - option read from config, or default
function asks user only if the option is not allready set in $SPELL_CONFIG
function also sets OPTION_NAME=answer supplied


Benefits & PR stuff:

- change should be painless ( select_list would call query_list, witch warning
being deprecated)
- uniform naming convention
- construct:
if ! grep -q "SASL" $SPELL_CONFIG; then
if query "Add SASL support in postfix ?" y
then echo "SASL=y" >> $SPELL_CONFIG ; SASL=y
else echo "SASL=n" >> $SPELL_CONFIG
fi
fi

is turned into:
config_query SASL "Add SASL support in postfix ?" y



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



  • [SM-Sorcery-Bugs] [Bug 6392] New: Improved API for query and store config information, bugzilla-daemon, 03/18/2004

Archive powered by MHonArc 2.6.24.

Top of Page