vty: Add a first version that runs a command.
This commit is contained in:
parent
826e3a0182
commit
cf071f9b49
45
OsmoVTY.st
45
OsmoVTY.st
|
@ -142,6 +142,51 @@ Object subclass: OSMOVTY [
|
|||
]
|
||||
]
|
||||
|
||||
Object subclass: VTYCommand [
|
||||
<comment: 'I represent a vty command'>
|
||||
<category: 'libosmovty-st'>
|
||||
|
||||
| command callback |
|
||||
|
||||
VTYCommand class >> initWith: aCommand help: aHelp [
|
||||
<category: 'creation'>
|
||||
"Create a new command. The memory is allocated permamently"
|
||||
|
||||
| command |
|
||||
command := Vty_cmd_element new.
|
||||
command name value: aCommand.
|
||||
command doc value: aHelp.
|
||||
|
||||
^ (self new)
|
||||
command: command;
|
||||
yourself.
|
||||
]
|
||||
|
||||
handleCommand: aCmd vty: aVty argc: aArgc argv: aArgv [
|
||||
aCmd inspect.
|
||||
aVty inspect.
|
||||
aArgc inspect.
|
||||
aArgv inspect.
|
||||
Transcript show: 'abc'; nl.
|
||||
^ 0
|
||||
]
|
||||
|
||||
command: aCommand [
|
||||
<category: 'private'>
|
||||
|
||||
command := aCommand.
|
||||
callback := CCallbackDescriptor
|
||||
for: [ :cmd :vty :argc :argv | self handleCommand: cmd vty: vty argc: argc argv: argv.]
|
||||
returning: #int
|
||||
withArgs: #(#cObject #cObject #int #(#ptr #string)).
|
||||
command func value: callback.
|
||||
]
|
||||
command [
|
||||
<category: 'command'>
|
||||
^ command
|
||||
]
|
||||
]
|
||||
|
||||
Eval [
|
||||
OSMOVTY initialize.
|
||||
]
|
||||
|
|
Reference in New Issue