Closed mpenning closed 7 years ago
Hi @mpenning
I have tested argument validation using the mock.hy example and it works as I expected it to for commands of type "output", which is what you are using.
Have a look at https://github.com/ncouture/MockSSH/blob/master/examples/mock.hy and see if you are using it differently.
testuser@0's password:
hostname>ls
MockSSH: supported usage: ls -1
hostname>ls -1 2 3 4
MockSSH: supported usage: ls -1
hostname>ls -1
bin/
README.txt
hostname>
As per your code a way to accept no argument would be like so:
(command :name "term"
:type "output"
:args []
:on-success ["prompt" *MockPrompt15*]
:on-failure ["write" *SyntaxError*])])
(mockssh)self ~/MockSSH $ pip freeze
MockSSH==1.4.2
Twisted==15.0.0
argparse==1.2.1
astor==0.4.1
ecdsa==0.13
hy==0.10.1
paramiko==1.15.2
pyasn1==0.1.7
pycrypto==2.6.1
rply==0.7.3
wsgiref==0.1.2
zope.interface==4.1.2
If this does not work try using version 1.4.2 I doubt it is related to the version you are using.
You are raising a good question as I designed the command argument validator to expect a single set of specific arguments which may very well not be representative of the real world, then again I don't think it's right to say "this command should expect N arguments regardless of what they are" so allowing definition of multiple aruments may be the way to go (patches accepted).
What is your use case?
I'm trying to build a hy-based test fixture, but I'm hitting a wall when it comes to command validation... this is my script:
The problem is no matter what I type for
term ...
, the session gladly accepts it. Using the example above...I wanted the script to require a literal
term len 0
; however, it takes anything. Is this expected behavior? Is there a way to fix themocksshy
script above?Version info (all on Debian linux 7.1, Python 2.7.3, kernel 3.2.0)...