-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·50 lines (41 loc) · 900 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·50 lines (41 loc) · 900 Bytes
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
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const Tuc = require('tuc');
const tuc = new Tuc();
var cardnumber = '';
const cli = meow(`
Usage
tuc <tuc_number>
Options
-t, --type Tuc card type
Example
$ tuc 00759795
30.00
$ tuc 00759795 -t
Cuenta limitada (sin movil)
`, {
alias: {
t: 'type'
}
});
function padDigits(number, digits) {
return Array(Math.max(digits - String(number).length + 1, 0)).join(0) + number;
}
if (cli.input.length === 0) {
console.error('Please specify a tuc number');
process.exit(1);
}
if (cli.input[0].toString().length < 8) {
cardnumber = padDigits(cli.input[0].toString(), 8);
} else {
cardnumber = cli.input[0].toString();
}
if (cli.flags.t) {
tuc.getType(cardnumber, function (type) {
console.log(type);
});
}
tuc.getBalance(cardnumber, function (balance) {
console.log(balance);
});