-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod.ts
99 lines (83 loc) · 3.35 KB
/
mod.ts
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
96
97
98
99
// Copyright 2020- Szalay Kristóf. All rights reserved. MIT license.
import { Args, parse } from "./deps.ts";
import { KopoOptions, Settings } from "./settings.ts";
import { Theme } from "./theme.ts";
import { HomePage } from "./pages/home_page.ts";
import { UI } from "./ui.ts";
import { settingsCLI } from "./cli/settings_cli.ts";
import { RegistryHandler } from "./registries/registry_handler.ts";
import { search } from "./cli/search_cli.ts";
import { upInCL } from "./utils.ts";
/*
/\ /\
| || |
..___[.][.] \ ________
| \ / ______|
\_____ \______________________/ /
| /
\ |
\ |
| | _____________| /
____|__/ ___/ \_ \ |
/ __________/ \ |\ |
|_| | | | | | |
| | | | | |
_/ / _/ / _/ /
|___/ |___/ |___/
____________________________________________________
KOPO CLI
*/
// deno run --allow-net --unstable --location https://kopo.mod.land mod.ts ui
// deno run --allow-net --unstable --location https://kopo.mod.land --allow-write --allow-read mod.ts settings import ./test.json --yes
async function startUI(args: Args) {
if (await Settings.getKopoOption(KopoOptions.cls)) {
UI.cls();
}
if(await Settings.getKopoOption(KopoOptions.winprint)) {
Deno.stdout.write = ((x: any) => { console.log(new TextDecoder().decode(x) + upInCL(1));}) as any;
}
console.log(); // so upInCL+clear doesnt jump
await HomePage.show(args);
}
async function run() {
const parsedArgs = parse(Deno.args, {
boolean: ["json", "readme", "readme-raw", "exact", "yes", "flags"],
alias: { e: "exact", v: "version", y: "yes" },
});
await Theme.init();
await RegistryHandler.initRegistries(parsedArgs);
if (parsedArgs._?.length) {
const cmd = parsedArgs._[0];
switch (cmd) {
case "search":
await search(parsedArgs);
break;
case "ui":
await startUI(parsedArgs);
break;
case "settings": {
await settingsCLI(parsedArgs);
break;
}
}
} else {
await startUI(parsedArgs);
}
}
await run();
// deno run --allow-net --no-check mod.ts search pretty
// deno run --allow-net --no-check mod.ts search pretty --json
// deno run --allow-net --no-check mod.ts search pretty_benching -e
// deno run --allow-net --no-check mod.ts search pretty_benching -e --version v0.1.1
// deno run --allow-net --no-check mod.ts search pretty_benching -e --json
// deno run --allow-net --no-check mod.ts search pretty_benching -e --readme
// deno run --allow-net --no-check mod.ts search pretty_benching -e --readme-raw
// ---------
// --no-prompt
// if no registry is defined (-d / -n) in a --readme search eg., select deno, or next in line.
// otherwise, if found in multiple registries give a prompt for the user to select from. but they should be the same...
// -e --detailed
// gives all versions, others from json output + readme by default?!
// search from an import route
// kopo find?? https://deno.land/x/kopo@v0.0.2/parse_flags.ts -> kopo search kopo -e -v v0.0.2
// TODO test with module husky