deno.land / x / lume@v2.1.4 / core / utils / cli_options.ts

cli_options.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
import { parseArgs } from "../../deps/cli.ts";import type { DeepPartial } from "./object.ts";import type { SiteOptions } from "../site.ts";
export function getOptionsFromCli(): DeepPartial<SiteOptions> { const options = parseArgs(Deno.args, { string: ["src", "dest", "location", "port"], boolean: ["serve", "open"], alias: { dev: "d", serve: "s", port: "p", open: "o" }, ["--"]: true, });
const overrides: DeepPartial<SiteOptions> = {};
if (options.src) { overrides.src = options.src; }
if (options.dest) { overrides.dest = options.dest; }
if (options.location) { overrides.location = new URL(options.location); } else if (options.serve || options._[0] === "cms") { overrides.location = new URL(`http://localhost:${options.port || 3000}/`); }
if (options.port) { (overrides.server ||= {}).port = parseInt(options.port);
if (overrides.location) { overrides.location.port = options.port; } }
if (options.open) { (overrides.server ||= {}).open = options.open; }
return overrides;}
lume

Version Info

Tagged at
7 months ago