mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 16:30:11 +00:00
Allow TO keyword to be omitted.
If the TO keyword is missing, assume the last file passed in is the destination file.
This commit is contained in:
parent
f80c333361
commit
43cd1c7e52
@ -47,7 +47,6 @@ function main() {
|
|||||||
opts = getOpts( a );
|
opts = getOpts( a );
|
||||||
logMsg( title );
|
logMsg( title );
|
||||||
|
|
||||||
|
|
||||||
// Get the action to be performed
|
// Get the action to be performed
|
||||||
var params = a._.map( function(p){ return p.toLowerCase().trim(); });
|
var params = a._.map( function(p){ return p.toLowerCase().trim(); });
|
||||||
var verb = params[0];
|
var verb = params[0];
|
||||||
@ -56,7 +55,7 @@ function main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get source and dest params
|
// Find the TO keyword, if any
|
||||||
var splitAt = _.indexOf( params, 'to' );
|
var splitAt = _.indexOf( params, 'to' );
|
||||||
if( splitAt === a._.length - 1 ) {
|
if( splitAt === a._.length - 1 ) {
|
||||||
// 'TO' cannot be the last argument
|
// 'TO' cannot be the last argument
|
||||||
@ -66,8 +65,10 @@ function main() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Massage inputs and outputs
|
||||||
var src = a._.slice(1, splitAt === -1 ? undefined : splitAt );
|
var src = a._.slice(1, splitAt === -1 ? undefined : splitAt );
|
||||||
var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 );
|
var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 );
|
||||||
|
( splitAt === -1 ) && dst.push( src.pop() ); // Allow omitting TO keyword
|
||||||
var parms = [ src, dst, opts, logMsg ];
|
var parms = [ src, dst, opts, logMsg ];
|
||||||
|
|
||||||
// Invoke the action
|
// Invoke the action
|
||||||
|
Loading…
Reference in New Issue
Block a user