daiso 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,7 @@ CLI (npx):
41
41
 
42
42
  ```bash
43
43
  npx daiso help
44
+ npx daiso help products
44
45
  npx daiso url
45
46
  npx daiso health
46
47
  npx daiso claude
package/dist/cli.js CHANGED
@@ -8,6 +8,7 @@ import { existsSync, readFileSync } from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
10
  import { spawn } from 'node:child_process';
11
+ import { printCommandHelp, printHelp } from './cliHelp.js';
11
12
  const DEFAULT_BASE_URL = 'https://mcp.aka.page';
12
13
  const DEFAULT_MCP_URL = `${DEFAULT_BASE_URL}/mcp`;
13
14
  function loadVersion() {
@@ -20,34 +21,6 @@ function loadVersion() {
20
21
  const parsed = JSON.parse(raw);
21
22
  return parsed.version ?? '0.0.0';
22
23
  }
23
- function printHelp(writeOut) {
24
- writeOut('daiso CLI');
25
- writeOut('');
26
- writeOut('사용법:');
27
- writeOut(' daiso <command> [options]');
28
- writeOut('');
29
- writeOut('명령어:');
30
- writeOut(' help 도움말 출력');
31
- writeOut(' version CLI 버전 출력');
32
- writeOut(' url MCP 엔드포인트 URL 출력');
33
- writeOut(' health 원격 서버 상태 확인');
34
- writeOut(' claude Claude Code MCP 등록 명령 출력');
35
- writeOut(' claude --exec Claude Code MCP 등록 명령 실행');
36
- writeOut(' get 임의 API 경로 GET 호출');
37
- writeOut(' products 다이소 제품 검색');
38
- writeOut(' product 다이소 제품 상세 조회');
39
- writeOut(' stores 다이소 매장 검색');
40
- writeOut(' inventory 다이소 재고 조회');
41
- writeOut('');
42
- writeOut('예시:');
43
- writeOut(' npx daiso url');
44
- writeOut(' npx daiso health');
45
- writeOut(' npx daiso claude');
46
- writeOut(' npx daiso products 수납박스');
47
- writeOut(' npx daiso stores 강남역');
48
- writeOut(' npx daiso inventory 1034604 --keyword 강남역');
49
- writeOut(' npx daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056');
50
- }
51
24
  async function execCommand(command, args) {
52
25
  return await new Promise((resolve, reject) => {
53
26
  const child = spawn(command, args, {
@@ -144,6 +117,10 @@ export async function runCli(argv, deps) {
144
117
  };
145
118
  const [command, ...options] = argv;
146
119
  if (!command || command === 'help' || command === '--help' || command === '-h') {
120
+ const maybeCommand = options[0];
121
+ if (maybeCommand) {
122
+ return printCommandHelp(maybeCommand, resolvedDeps.writeOut, resolvedDeps.writeErr);
123
+ }
147
124
  printHelp(resolvedDeps.writeOut);
148
125
  return 0;
149
126
  }
@@ -193,6 +170,9 @@ export async function runCli(argv, deps) {
193
170
  }
194
171
  if (command === 'get') {
195
172
  const parsed = parseCliArgs(options);
173
+ if (parsed.options.help === 'true') {
174
+ return printCommandHelp('get', resolvedDeps.writeOut, resolvedDeps.writeErr);
175
+ }
196
176
  const targetPath = parsed.positionals[0];
197
177
  if (!targetPath) {
198
178
  resolvedDeps.writeErr('get 명령은 경로가 필요합니다. 예: daiso get /api/daiso/products --q 수납박스');
@@ -204,6 +184,9 @@ export async function runCli(argv, deps) {
204
184
  }
205
185
  if (command === 'products') {
206
186
  const parsed = parseCliArgs(options);
187
+ if (parsed.options.help === 'true') {
188
+ return printCommandHelp('products', resolvedDeps.writeOut, resolvedDeps.writeErr);
189
+ }
207
190
  const query = parsed.positionals[0];
208
191
  if (!query) {
209
192
  resolvedDeps.writeErr('products 명령은 검색어가 필요합니다. 예: daiso products 수납박스');
@@ -216,6 +199,9 @@ export async function runCli(argv, deps) {
216
199
  }
217
200
  if (command === 'product') {
218
201
  const parsed = parseCliArgs(options);
202
+ if (parsed.options.help === 'true') {
203
+ return printCommandHelp('product', resolvedDeps.writeOut, resolvedDeps.writeErr);
204
+ }
219
205
  const productId = parsed.positionals[0];
220
206
  if (!productId) {
221
207
  resolvedDeps.writeErr('product 명령은 제품 ID가 필요합니다. 예: daiso product 1034604');
@@ -227,6 +213,9 @@ export async function runCli(argv, deps) {
227
213
  }
228
214
  if (command === 'stores') {
229
215
  const parsed = parseCliArgs(options);
216
+ if (parsed.options.help === 'true') {
217
+ return printCommandHelp('stores', resolvedDeps.writeOut, resolvedDeps.writeErr);
218
+ }
230
219
  const keyword = parsed.positionals[0];
231
220
  if (keyword) {
232
221
  parsed.options.keyword = keyword;
@@ -241,6 +230,9 @@ export async function runCli(argv, deps) {
241
230
  }
242
231
  if (command === 'inventory') {
243
232
  const parsed = parseCliArgs(options);
233
+ if (parsed.options.help === 'true') {
234
+ return printCommandHelp('inventory', resolvedDeps.writeOut, resolvedDeps.writeErr);
235
+ }
244
236
  const productId = parsed.positionals[0];
245
237
  if (!productId) {
246
238
  resolvedDeps.writeErr('inventory 명령은 제품 ID가 필요합니다. 예: daiso inventory 1034604 --keyword 강남역');
@@ -0,0 +1,133 @@
1
+ /**
2
+ * CLI 도움말 정의
3
+ */
4
+ export const COMMAND_LIST = [
5
+ 'help',
6
+ 'version',
7
+ 'url',
8
+ 'health',
9
+ 'claude',
10
+ 'get',
11
+ 'products',
12
+ 'product',
13
+ 'stores',
14
+ 'inventory',
15
+ ];
16
+ const COMMAND_SUMMARY = {
17
+ help: '도움말 출력',
18
+ version: 'CLI 버전 출력',
19
+ url: 'MCP 엔드포인트 URL 출력',
20
+ health: '원격 서버 상태 확인',
21
+ claude: 'Claude Code MCP 등록 명령 출력/실행',
22
+ get: '임의 API 경로 GET 호출',
23
+ products: '다이소 제품 검색',
24
+ product: '다이소 제품 상세 조회',
25
+ stores: '다이소 매장 검색',
26
+ inventory: '다이소 재고 조회',
27
+ };
28
+ const COMMAND_DETAIL = {
29
+ help: [
30
+ '명령: help',
31
+ '설명: 전체 도움말 또는 특정 명령 상세 도움말을 출력합니다.',
32
+ '사용법: daiso help [command]',
33
+ '예시: daiso help products',
34
+ ],
35
+ version: [
36
+ '명령: version',
37
+ '설명: 설치된 daiso CLI 버전을 출력합니다.',
38
+ '사용법: daiso version',
39
+ ],
40
+ url: [
41
+ '명령: url',
42
+ '설명: MCP 엔드포인트 URL을 출력합니다.',
43
+ '사용법: daiso url',
44
+ '출력 예시: https://mcp.aka.page/mcp',
45
+ ],
46
+ health: [
47
+ '명령: health',
48
+ '설명: 서버 /health API를 호출해 상태를 확인합니다.',
49
+ '사용법: daiso health',
50
+ '출력: status, endpoint, checkedAt(JSON)',
51
+ ],
52
+ claude: [
53
+ '명령: claude',
54
+ '설명: Claude Code MCP 등록 명령을 출력하거나 실행합니다.',
55
+ '사용법: daiso claude [--exec]',
56
+ '옵션: --exec 실제 claude 명령 실행',
57
+ '예시: daiso claude --exec',
58
+ ],
59
+ get: [
60
+ '명령: get',
61
+ '설명: 임의 API 경로를 GET으로 호출합니다.',
62
+ '사용법: daiso get <path|url> [--queryKey value ...]',
63
+ '필수: <path|url>',
64
+ '예시: daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056',
65
+ ],
66
+ products: [
67
+ '명령: products',
68
+ '설명: 다이소 제품 검색 API를 호출합니다.',
69
+ '사용법: daiso products <query> [--page N] [--pageSize N]',
70
+ '필수: <query>',
71
+ '옵션: --page, --pageSize',
72
+ '예시: daiso products 수납박스 --page 1 --pageSize 30',
73
+ ],
74
+ product: [
75
+ '명령: product',
76
+ '설명: 다이소 제품 상세 API를 호출합니다.',
77
+ '사용법: daiso product <productId>',
78
+ '필수: <productId>',
79
+ '예시: daiso product 1034604',
80
+ ],
81
+ stores: [
82
+ '명령: stores',
83
+ '설명: 다이소 매장 검색 API를 호출합니다.',
84
+ '사용법: daiso stores [keyword] [--sido 값] [--gugun 값] [--dong 값] [--limit N]',
85
+ '필수: keyword 또는 --sido',
86
+ '옵션: --keyword, --sido, --gugun, --dong, --limit',
87
+ '예시: daiso stores 강남역',
88
+ '예시: daiso stores --sido 서울 --gugun 강남구',
89
+ ],
90
+ inventory: [
91
+ '명령: inventory',
92
+ '설명: 다이소 재고 API를 호출합니다.',
93
+ '사용법: daiso inventory <productId> [--keyword 값] [--lat 값] [--lng 값] [--page N] [--pageSize N]',
94
+ '필수: <productId>',
95
+ '옵션: --keyword, --lat, --lng, --page, --pageSize',
96
+ '예시: daiso inventory 1034604 --keyword 강남역',
97
+ ],
98
+ };
99
+ export function printHelp(writeOut) {
100
+ writeOut('daiso CLI');
101
+ writeOut('');
102
+ writeOut('사용법:');
103
+ writeOut(' daiso <command> [options]');
104
+ writeOut('');
105
+ writeOut('명령어:');
106
+ for (const command of COMMAND_LIST) {
107
+ writeOut(` ${command.padEnd(20, ' ')}${COMMAND_SUMMARY[command]}`);
108
+ }
109
+ writeOut('');
110
+ writeOut('예시:');
111
+ writeOut(' npx daiso url');
112
+ writeOut(' npx daiso health');
113
+ writeOut(' npx daiso claude');
114
+ writeOut(' npx daiso products 수납박스');
115
+ writeOut(' npx daiso stores 강남역');
116
+ writeOut(' npx daiso inventory 1034604 --keyword 강남역');
117
+ writeOut(' npx daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056');
118
+ writeOut('');
119
+ writeOut('상세 도움말:');
120
+ writeOut(' npx daiso help <command>');
121
+ }
122
+ export function printCommandHelp(command, writeOut, writeErr) {
123
+ if (!Object.hasOwn(COMMAND_DETAIL, command)) {
124
+ writeErr(`도움말을 찾을 수 없는 명령어: ${command}`);
125
+ writeErr('사용 가능한 명령어: help, version, url, health, claude, get, products, product, stores, inventory');
126
+ return 1;
127
+ }
128
+ const detail = COMMAND_DETAIL[command];
129
+ for (const line of detail) {
130
+ writeOut(line);
131
+ }
132
+ return 0;
133
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daiso",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Daiso MCP Server for mobile access via Cloudflare Workers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {