-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Meme における位置引数のサポートとリファクタ (#749)
- Loading branch information
1 parent
aa1d53f
commit 56b2316
Showing
23 changed files
with
315 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
export interface ParsedArgs< | ||
FLAGS_KEY extends string, | ||
OPTIONS_KEY extends string | ||
FLAGS_KEY extends string = never, | ||
OPTIONS_KEY extends string = never, | ||
REQ_POSITIONAL_KEY extends string = never, | ||
OPT_POSITIONAL_KEY extends string = never | ||
> { | ||
flags: Record<FLAGS_KEY, boolean | undefined>; | ||
options: Record<OPTIONS_KEY, string | undefined>; | ||
body: string; | ||
requiredPositionals: Record<REQ_POSITIONAL_KEY, string>; | ||
optionalPositionals: Record<OPT_POSITIONAL_KEY, string | undefined>; | ||
} | ||
|
||
export interface MemeTemplate< | ||
FLAGS_KEY extends string, | ||
OPTIONS_KEY extends string | ||
FLAGS_KEY extends string = never, | ||
OPTIONS_KEY extends string = never, | ||
REQ_POSITIONAL_KEY extends string = never, | ||
OPT_POSITIONAL_KEY extends string = never | ||
> { | ||
commandNames: readonly string[]; | ||
description: string; | ||
flagsKeys: readonly FLAGS_KEY[]; | ||
optionsKeys: readonly OPTIONS_KEY[]; | ||
flagsKeys?: readonly FLAGS_KEY[]; | ||
optionsKeys?: readonly OPTIONS_KEY[]; | ||
requiredPositionalKeys?: readonly REQ_POSITIONAL_KEY[]; | ||
optionalPositionalKeys?: readonly OPT_POSITIONAL_KEY[]; | ||
errorMessage: string; | ||
generate(args: ParsedArgs<FLAGS_KEY, OPTIONS_KEY>, author: string): string; | ||
generate( | ||
args: ParsedArgs< | ||
FLAGS_KEY, | ||
OPTIONS_KEY, | ||
REQ_POSITIONAL_KEY, | ||
OPT_POSITIONAL_KEY | ||
>, | ||
author: string | ||
): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import type { MemeTemplate } from '../../../model/meme-template.js'; | ||
|
||
export const clang: MemeTemplate<never, never> = { | ||
const positionalKeys = ['domain', 'way'] as const; | ||
|
||
export const clang: MemeTemplate< | ||
never, | ||
never, | ||
(typeof positionalKeys)[number] | ||
> = { | ||
commandNames: ['clang', 'c'], | ||
description: '〜の天才\n9つの〜を操る', | ||
flagsKeys: [], | ||
optionsKeys: [], | ||
requiredPositionalKeys: positionalKeys, | ||
errorMessage: 'エラーの天才\n9つの引数エラーを操る', | ||
generate(args) { | ||
const [option1, option2] = args.body.split(' '); | ||
return `${option1}の天才\n9つの${option2}を操る`; | ||
generate({ requiredPositionals: { domain, way } }) { | ||
return `${domain}の天才\n9つの${way}を操る`; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import type { MemeTemplate } from '../../../model/meme-template.js'; | ||
|
||
export const dousurya: MemeTemplate<never, never> = { | ||
const positionalKeys = ['living'] as const; | ||
|
||
export const dousurya: MemeTemplate< | ||
never, | ||
never, | ||
(typeof positionalKeys)[number] | ||
> = { | ||
commandNames: ['dousurya', 'dousureba'], | ||
description: '限界みたいな鯖に住んでる〜はどうすりゃいいですか?', | ||
flagsKeys: [], | ||
optionsKeys: [], | ||
requiredPositionalKeys: positionalKeys, | ||
errorMessage: 'どうしようもない。', | ||
generate(args) { | ||
return `限界みたいな鯖に住んでる${args.body}はどうすりゃいいですか?`; | ||
return `限界みたいな鯖に住んでる${args.requiredPositionals.living}はどうすりゃいいですか?`; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import type { MemeTemplate } from '../../../model/meme-template.js'; | ||
|
||
export const hukueki: MemeTemplate<never, never> = { | ||
const positionalKeys = ['badThing'] as const; | ||
|
||
export const hukueki: MemeTemplate< | ||
never, | ||
never, | ||
(typeof positionalKeys)[number] | ||
> = { | ||
commandNames: ['hukueki'], | ||
description: 'ねぇ、将来何してるだろうね\n〜はしてないといいね\n困らないでよ', | ||
flagsKeys: [], | ||
optionsKeys: [], | ||
requiredPositionalKeys: positionalKeys, | ||
errorMessage: '服役できなかった。', | ||
generate(args) { | ||
return `ねぇ、将来何してるだろうね\n${args.body}はしてないといいね\n困らないでよ`; | ||
return `ねぇ、将来何してるだろうね\n${args.requiredPositionals.badThing}はしてないといいね\n困らないでよ`; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import type { MemeTemplate } from '../../../model/meme-template.js'; | ||
|
||
export const kenjou: MemeTemplate<never, never> = { | ||
const positionalKeys = ['title'] as const; | ||
|
||
export const kenjou: MemeTemplate< | ||
never, | ||
never, | ||
(typeof positionalKeys)[number] | ||
> = { | ||
commandNames: ['kenjou'], | ||
description: | ||
'[健常者エミュレーター](https://healthy-person-emulator.memo.wiki/)の構文ジェネレーター。\n健常者エミュレーターWikiにありそうなタイトルを指定すればうまくいきます。', | ||
flagsKeys: [], | ||
optionsKeys: [], | ||
requiredPositionalKeys: positionalKeys, | ||
errorMessage: | ||
'はらちょのミーム機能を使うときは引数を忘れない方がいい - 健常者エミュレータ事例集Wiki', | ||
generate(args) { | ||
return `${args.body} - 健常者エミュレータ事例集Wiki`; | ||
return `${args.requiredPositionals.title} - 健常者エミュレータ事例集Wiki`; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import type { MemeTemplate } from '../../../model/meme-template.js'; | ||
|
||
export const koume: MemeTemplate<never, never> = { | ||
const positionalKeys = ['expected', 'actual'] as const; | ||
|
||
export const koume: MemeTemplate< | ||
never, | ||
never, | ||
(typeof positionalKeys)[number] | ||
> = { | ||
commandNames: ['koume'], | ||
description: '〜と思ったら〜♪\n\n〜でした〜♪\n\n引数は2つ必要です。', | ||
flagsKeys: [], | ||
optionsKeys: [], | ||
requiredPositionalKeys: positionalKeys, | ||
errorMessage: | ||
'MEMEを表示しようと思ったら〜♪ 引数が足りませんでした〜♪ チクショー!!', | ||
generate(args) { | ||
const [option1, option2] = args.body.split(' '); | ||
generate({ requiredPositionals: { expected, actual } }) { | ||
// Reason: 構文とコウメ太夫に敬意を払い、元ネタを尊重することから全角スペースを使用したいのでeslintの警告をBANします。 | ||
// eslint-disable-next-line no-irregular-whitespace | ||
return `${option1}と思ったら〜♪\n\n${option2}でした〜♪\n\nチクショー!! #まいにちチクショー`; | ||
return `${expected}と思ったら〜♪\n\n${actual}でした〜♪\n\nチクショー!! #まいにちチクショー`; | ||
} | ||
}; |
Oops, something went wrong.