MCPcopy Create free account
hub / github.com/Tatamo/atcoder-cli / convert

Function convert

src/project.ts:215–230  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

213
214export function formatContestDirname(format: string, contest: Contest): string {
215 const convert = (pattern: string): string => {
216 switch (pattern) {
217 case "ContestID":
218 return contest.id;
219 case "CONTESTID":
220 return contest.id.toUpperCase();
221 case "TailNumberOfContestID":
222 const result = /\d+$/.exec(contest.id);
223 return result === null ? "" : result[0];
224 case "ContestTitle":
225 return contest.title;
226 }
227 throw new Error(
228 `pattern "{${pattern}} is not defined. use --help option to get more information."`
229 );
230 };
231 return format.replace(/{([a-zA-Z0-9]+)}/g, (_, p) => convert(p));
232}
233

Callers 2

formatContestDirnameFunction · 0.85
formatTaskDirnameFunction · 0.85

Calls 1

convertNumber2AlphabetFunction · 0.85

Tested by

no test coverage detected