-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
controller.ts
32 lines (28 loc) · 909 Bytes
/
controller.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
// Copyright 2020 the Fastro author. All rights reserved. MIT license.
import { FASTRO_VERSION } from "../core/types.ts";
import { watch } from "./watch.ts";
import {
create,
getArguments,
handleDeploy,
handleHelp,
handleRegister,
init,
serve,
} from "./handler.ts";
const args = getArguments(Deno.args);
const { command: [cmd], port, production, email, version } = args;
if (!production && cmd === "serve" && !args.help) await watch();
export function start() {
try {
if (cmd === "init") return init(args);
if (cmd === "create") return create(args);
if (cmd === "serve") return serve(port, args);
if (cmd === "deploy") return handleDeploy(args);
if (cmd === "register") return handleRegister(email, args);
if (version) return console.info(`fastro ${FASTRO_VERSION}`);
handleHelp();
} catch (error) {
console.error(`${error.name}:`, error.message);
}
}