-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
95 lines (82 loc) · 2.39 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env node
// Width: 102
// Height: 32
// Imports
// import { homedir } from 'os'
// import * as fs from 'fs';
// import fsPromises from 'fs/promises';
// import * as path from 'path';
// import chalk from 'chalk';
import inquirer from 'inquirer';
// import gradient from 'gradient-string';
// import chalkAnimation from 'chalk-animation';
// import { createSpinner } from 'nanospinner';
// import AdmZip from 'adm-zip';
// import * as shortcuts from 'windows-shortcuts';
// Local imports
// import globals from './src/variables/globals.js';
// import config from './src/config/config.js';
// import funcs from './src/functions/general.js';
import ui from './src/functions/ui.js';
import splash from './src/pages/splash.js';
import slice from './src/pages/slice.js';
import unslice from './src/pages/unslice.js';
import help from './src/pages/help.js';
import configuration from './src/pages/configuration.js';
import test from './src/pages/test.js';
// ============= COMMANDS ========================================================================
// Main operation input
/*
Function to get the command input from a list. This is then used to decide which function to show
Uses sliceOperation global variable
*/
async function commandAskOperation() {
const answer = await inquirer.prompt({
name: 'sliceOperation',
type: 'list',
message: 'Please select a command using the arrow keys and enter\n',
choices: [
'Slice',
'Un-Slice',
'Help',
'Configuration',
'Test',
'Quit'
]
});
return answer.sliceOperation;
}
// ============= NAVIGATION ======================================================================
async function mainMenu() {
// Default menu headers
ui.printHeader();
const op = await commandAskOperation();
// Command input handler
switch(op) {
case "Slice":
await slice.view();
break;
case "Un-Slice":
await unslice.view();
break;
case "Help":
await help.view();
break;
case "Configuration":
await configuration.view();
break;
case "Test":
await test.display();
await ui.backToMenu();
break;
case "Quit":
console.clear();
process.exit(0);
}
mainMenu();
}
// ============= WORKFLOW ========================================================================
// Application
console.clear();
await splash.start();
await mainMenu();