This is kind of a weird use-case, but it might be nice to allow plugin writers to create commands of the following form (tr() is the example):
var ret = shell.cat('file.txt').tr('-d', 'A'); // ShellStrings have a .tr() method
assert.equal(shell.hasOwnProperty('tr'), false); // The shell.tr() command doesn't exist
This example would stay consistent with how the unix tr command works, since it doesn't actually take a filename as an argument and can only be used via pipes.
This is related to #486, but I think there's an important distinction. This still takes advantage of option parsing and perhaps other features of the plugin API. #486 is more about adding pure methods without any sort of wrapping, or completely changing the implementation of ShellStrings.
This functionality could be offered as an option to plugin.register:
plugin.register('tr', _tr, {
wrapOutput: true,
cmdOptions: {
d: 'delete',
},
canReceivePipe: true,
pipedOnly: true, // perhaps there's a way to tie this in to the option above
});