1
# ----------------------------------------------------------------------------
3
# - afnix:amd option database module -
4
# ----------------------------------------------------------------------------
5
# - This program is free software; you can redistribute it and/or modify -
6
# - it provided that this copyright notice is kept intact. -
8
# - This program is distributed in the hope that it will be useful, but -
9
# - without any warranty; without even the implied warranty of -
10
# - merchantability or fitness for a particular purpose. In not event shall -
11
# - the copyright holder be liable for any direct, indirect, incidental or -
12
# - special damages arising in any way out of the use of this software. -
13
# ----------------------------------------------------------------------------
14
# - copyright (c) 1999-2011 amaury darsch -
15
# ----------------------------------------------------------------------------
17
# ----------------------------------------------------------------------------
19
# ----------------------------------------------------------------------------
21
# the option database class
22
const afnix:amd:optdb (class)
24
# ----------------------------------------------------------------------------
26
# ----------------------------------------------------------------------------
29
const AFNIX:AMD:U-CLS-MSG "axi [i afnix-amd] amd-start [options] uri"
30
const AFNIX:AMD:H-LCO-MSG " [h] print this help message"
31
const AFNIX:AMD:V-LCO-MSG " [v] print system version"
32
const AFNIX:AMD:O-LCO-MSG " [o] set output file name"
34
# ----------------------------------------------------------------------------
36
# ----------------------------------------------------------------------------
38
# initialize the option descriptors
39
trans afnix:amd:optdb:preset (argv) {
40
# create an option class and bind it
41
trans this:super (afnix:sys:Options AFNIX:AMD:U-CLS-MSG)
43
# register the options
44
this:add-string-option 'o' AFNIX:AMD:O-LCO-MSG
45
this:add-unique-option 'v' AFNIX:AMD:V-LCO-MSG
46
this:add-unique-option 'h' AFNIX:AMD:H-LCO-MSG
49
try (this:parse argv) {
50
this:usage (interp:get-error-stream)
53
# check for the help option
54
if (this:get-unique-option 'h') {
55
this:usage (interp:get-output-stream)
58
# check for the version option
59
if (this:get-unique-option 'v') {
60
println (afnix:amd:get-copyright-message)
61
println (afnix:amd:get-revision-message)
64
# check for the output file name
65
if (this:get-unique-option 'o') {
66
trans afnix:amd:system-oflg true
67
trans afnix:amd:system-onam (this:get-string-option 'o')
69
# get the requested uri argument
70
const varg (this:get-vector-arguments)
71
if (!= (varg:length) 1) {
72
this:usage (interp:get-error-stream)
75
const this:uri (afnix:amd:get-uri-name (varg:get 0))
78
# ----------------------------------------------------------------------------
80
# ----------------------------------------------------------------------------
82
# @return the requested uri
84
trans afnix:amd:optdb:get-uri nil {
85
afnix:nwg:Uri this:uri