cli - use proper defaults
This commit is contained in:
parent
33603eabff
commit
4d8b0b85dd
1 changed files with 14 additions and 8 deletions
22
cli/main.ts
22
cli/main.ts
|
@ -11,13 +11,19 @@ import { walkSync } from "https://deno.land/std@0.107.0/fs/mod.ts";
|
||||||
|
|
||||||
const args = parse(Deno.args, {
|
const args = parse(Deno.args, {
|
||||||
alias: {
|
alias: {
|
||||||
"w": "width",
|
w: "width",
|
||||||
"h": "height",
|
h: "height",
|
||||||
"o": "output",
|
o: "output",
|
||||||
"m": "mode",
|
m: "mode",
|
||||||
"r": "recursive",
|
r: "recursive",
|
||||||
},
|
},
|
||||||
boolean: ["recursive"],
|
boolean: ["recursive"],
|
||||||
|
default: {
|
||||||
|
w: 640,
|
||||||
|
h: 640,
|
||||||
|
include: "*.png, *.jpg",
|
||||||
|
output: "collage.png"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (args["mode"] === true) {
|
if (args["mode"] === true) {
|
||||||
|
@ -27,7 +33,7 @@ if (args["mode"] === true) {
|
||||||
|
|
||||||
const files: Set<string> = new Set();
|
const files: Set<string> = new Set();
|
||||||
const includeExtensions = Array.from(
|
const includeExtensions = Array.from(
|
||||||
String(args["include"] || "*.png, *.jpg").matchAll(/\*\.([\w]+)/g),
|
String(args["include"]).matchAll(/\*\.([\w]+)/g),
|
||||||
).map(([_, group]) => group);
|
).map(([_, group]) => group);
|
||||||
|
|
||||||
args["_"].forEach((arg) => {
|
args["_"].forEach((arg) => {
|
||||||
|
@ -68,7 +74,7 @@ if (args["mode"]) {
|
||||||
allModeKeys.push(...displayCollageModeType);
|
allModeKeys.push(...displayCollageModeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const canvas = createCanvas(args["width"] || 640, args["height"] || 640);
|
const canvas = createCanvas(args["width"], args["height"]);
|
||||||
const context = canvas.getContext("2d");
|
const context = canvas.getContext("2d");
|
||||||
|
|
||||||
const collageConfig: CollageConfig = {
|
const collageConfig: CollageConfig = {
|
||||||
|
@ -98,6 +104,6 @@ if (modeKey === "recursive") {
|
||||||
mode.place(context, images, segments);
|
mode.place(context, images, segments);
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = args["output"] || "collage.png";
|
const output = args["output"];
|
||||||
console.log(`Saving to "${output}"...`);
|
console.log(`Saving to "${output}"...`);
|
||||||
await Deno.writeFile(output, canvas.toBuffer());
|
await Deno.writeFile(output, canvas.toBuffer());
|
||||||
|
|
Loading…
Reference in a new issue