-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (55 loc) · 1.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/env node
// --------------------------------------------------
// IMPORT MODULES
// --------------------------------------------------
// Project
require( './lib/setup' );
var main = require( './lib/main' );
var gitf = require( './lib/gitf' );
// --------------------------------------------------
// DECLARE VARS
// --------------------------------------------------
const PACKAGE_NAME = 'Familiar';
const PACKAGE_COMMAND ='gitf';
const args = process.argv.slice( 2 ) || [];
const commandWhitelist = [ 'commit' ];
var config = null;
// --------------------------------------------------
// DECLARE FUNCTIONS
// --------------------------------------------------
function parseArgs( args ) {
let command = args[ 0 ];
if ( !command ) {
printCommandError( 'MISSING_COMMAND' );
return; /// TEMP
}
applyCommand( command, args.slice( 1 ) );
}
function applyCommand( command, args ) {
if ( command in gitf ) {
gitf[ command ]( args, config );
} else {
console.log( `Whoops! The \`${command}\` command is not currently supported by ${PACKAGE_NAME}.`.error );
/// TODO[@jrmykolyn] - Throw error or 'fallthrough' to native Git command.
}
}
function printCommandError( errorType ) {
errorType = errorType || '';
switch ( errorType ) {
case 'MISSING_COMMAND':
console.log( `Whoops! Looks like you called \`${PACKAGE_COMMAND}\` without a command.`.error );
break;
default:
console.log( 'Whoops! Something went wrong!'.error );
}
}
// --------------------------------------------------
// INITIALIZE
// --------------------------------------------------
main.init().then(
( configData ) => {
config = configData;
parseArgs( args );
},
( err ) => { console.log( err ); }
);