Closed sidorenkobw closed 7 years ago
I didn't find a way to disable options validation but I found a workaround to this issue by using parse
. The idea is to replace whitespaces by whatever delimiter :
vorpal
.catch('[words...]', 'Exec shell commands')
.parse(command => command.split(' ').join('____'))
.action((args, cb) => {
const cmd = args.words[0].split('____').join(' ');
vorpal.log(cmd);
exec(cmd, { stdio : [0, 1, 2] });
cb();
});
Thank you, Matthieu!
As for vorpal, I think that ignoring options validation would be more logical way for processing catch command rather the current one. I also suggest to add ability to ignore options validation to any command in case if some one wants to make it in dynamic way.
Awesome project, BTW. Great job, guys!
My bad, there is a way to disable options validation, see #144.
You just have to call allowUnknownOptions()
:
vorpal
.catch('[words...]', 'Exec shell commands')
.allowUnknownOptions()
.action((args, cb) => {
const cmd = args.words.join(' ');
try {
exec(cmd, { stdio : 'inherit' });
} catch (e) {
vorpal.execSync('help');
}
cb();
});
Thank you Matthieu! Looks like it's not documented.
Added in the Wiki : allowUnknownOptions
Hi guys,
My idea is to create a shell which extends my current system shell. So I create my commands in vorpal and I want every input which is not a registered command to be executed in current system shell.
So I do the following:
It works fine unless I am trying to run some system shell command with options, like:
ls -l
In this case validation doesn't allow to run this callback saying:
Is there any way to disable options validation?
Thanks