-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.js
More file actions
49 lines (45 loc) · 1.24 KB
/
stack.js
File metadata and controls
49 lines (45 loc) · 1.24 KB
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
const fs = require('fs');
const _ = require('lodash');
const yargs = require('yargs');
const nameOptions = {
describe: 'The name of your stack',
demand: true,
alias: 'n'
};
const argv = yargs
.command('undo', 'Remove the last layer added to the stack')
.command('redo', 'Return the previously deleted layer to the stack')
.command('clear', 'Clear the stack')
.command('print', 'Print current stack')
.command('list', 'Print a list of archived stacks')
.command('save', 'Save your stack', {
name: nameOptions
})
.command('load', 'Load a saved stack', {
name: nameOptions
})
.help()
.argv;
const call = require('./call.js');
let command = argv._[0];
if (command === 'undo') {
call.undoLayer();
call.displayStack();
} else if (command === 'redo') {
call.redoLayer();
call.displayStack();
} else if (command === 'clear') {
call.clearStack();
} else if (command === 'save') {
call.archiveStack(argv.name);
} else if (command === 'load') {
call.loadStack(argv.name)
call.displayStack();
} else if (command === 'list') {
call.listStack();
} else if (command === 'print') {
call.displayStack();
} else {
call.addLayer(command);
call.displayStack();
}