From ce0fc9001e53c98f3fb4ca538239f16e7180cd81 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sun, 3 Dec 2023 17:35:19 +0900 Subject: [PATCH] usage --- README.md | 1 - main.ts | 39 +++++++++++++++++++++++++++++++++++++-- package-lock.json | 6 +++--- package.json | 4 ++-- platform.ts | 2 +- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e311aa8..cfdcd9d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ## Usage ``` -$ npx playwright@1.40.1 install --with-deps chromium $ npx https://git.fogtype.com/nebel/gadl/archive/main.tar.gz --help ``` diff --git a/main.ts b/main.ts index 6340013..a6cb048 100644 --- a/main.ts +++ b/main.ts @@ -2,24 +2,36 @@ import util from "node:util"; import { createBrowser } from "./browser"; import { createDatabase } from "./database"; import { type Book, createLibrary } from "./library"; -import { type TPlatform, createPlatform } from "./platform"; +import { type TPlatform, createPlatform, platforms } from "./platform"; import * as pkg from "./package.json"; const options = { db: { type: "string", default: "gadl.db", + toString() { + return ` (default: ${this.default})`; + }, }, "out-dir": { type: "string", default: "dist", + toString() { + return ` (default: ${this.default})`; + }, }, "out-authors-limit": { type: "string", default: "3", + toString() { + return ` (default: ${this.default})`; + }, }, login: { type: "string", + toString() { + return [...Object.keys(platforms)].join("|"); + }, async run() { const db = await createDatabase(args.values.db!); const browser = await createBrowser({ db, headless: false }); @@ -34,6 +46,9 @@ const options = { }, logout: { type: "string", + toString() { + return [...Object.keys(platforms)].join("|"); + }, async run() { const db = await createDatabase(args.values.db!); const browser = await createBrowser({ db }); @@ -48,6 +63,9 @@ const options = { }, add: { type: "string", + toString() { + return ``; + }, async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); @@ -56,6 +74,9 @@ const options = { }, delete: { type: "string", + toString() { + return ``; + }, async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); @@ -79,6 +100,9 @@ const options = { }, view: { type: "string", + toString() { + return ``; + }, async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); @@ -97,6 +121,9 @@ const options = { }, pull: { type: "string", + toString() { + return [...Object.keys(platforms)].join("|"); + }, async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); @@ -116,6 +143,9 @@ const options = { }, download: { type: "string", + toString() { + return `all|`; + }, async run() { const db = await createDatabase(args.values.db!); const library = createLibrary(db); @@ -170,12 +200,17 @@ const options = { run() { console.log( [ + "Usage: gadl [options...]", + ` $ npx playwright@${pkg.dependencies.playwright} install --with-deps chromium`, + ` $ gadl --login=`, + ` $ gadl --download=`, + "", "Available options:", ...Object.entries(options).map((option) => [ ` --${option[0]}`, "short" in option[1] && ` -${option[1].short}`, - option[1].type === "string" && "=", + option[1].type === "string" && `=${option[1]}`, ] .filter(Boolean) .join(""), diff --git a/package-lock.json b/package-lock.json index b3e588b..1891f64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@fogtype/gadl", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@fogtype/gadl", - "version": "1.3.0", + "version": "1.3.1", "license": "AGPL-3.0", "dependencies": { "fflate": "^0.8.1", - "playwright": "^1.40.1", + "playwright": "1.40.1", "sqlite": "^5.1.1", "sqlite3": "^5.1.6", "tsx": "^4.6.1" diff --git a/package.json b/package.json index 83f58f9..2abd57a 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "@fogtype/gadl", - "version": "1.3.0", + "version": "1.3.1", "license": "AGPL-3.0", "type": "module", "bin": "bin/run.js", "dependencies": { "fflate": "^0.8.1", - "playwright": "^1.40.1", + "playwright": "1.40.1", "sqlite": "^5.1.1", "sqlite3": "^5.1.6", "tsx": "^4.6.1" diff --git a/platform.ts b/platform.ts index 0210ed4..baf5a1c 100644 --- a/platform.ts +++ b/platform.ts @@ -8,7 +8,7 @@ import { DmmBooks } from "./platforms/dmm-books"; import { FanzaDoujin } from "./platforms/fanza-doujin"; import { GooglePlayBooks } from "./platforms/google-play-books"; -const platforms = { +export const platforms = { "dlsite-maniax": DlsiteManiax, "dmm-books": DmmBooks, "fanza-doujin": FanzaDoujin,