-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
executable file
·55 lines (46 loc) · 1.1 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
#!/usr/bin/env node
import Config from './src/config.js';
import Github from './src/github.js';
import UI from './src/ui.js';
import reposCommand from './src/commands/repos.js';
import codespacesCommand from './src/commands/codespaces.js';
UI.printWelcome();
const main = async () => {
try {
if (!Config.load()) {
const token = await UI.promptAuth();
Config.save(token);
}
const command = process.argv[2];
switch (command) {
case 'repos':
case 'repo':
case 'repository':
case 'repositories':
await reposCommand();
break;
case 'codespaces':
case 'codespace':
await codespacesCommand();
break;
case 'help':
UI.printHelp();
break;
default:
if (!command) {
// await reposCommand();
UI.printHelp();
break;
}
UI.printHelp();
}
} catch (error) {
if (error instanceof Github.AuthError || error instanceof Github.ScopesError) {
Config.deleteFile();
return await main();
}
UI.printError(error);
return;
}
};
main();