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

Function formatTaskDirname

src/project.ts:234–272  ·  view source on GitHub ↗
(format: string, task: Task, index: number, contest: Contest)

Source from the content-addressed store, hash-verified

232}
233
234export function formatTaskDirname(format: string, task: Task, index: number, contest: Contest): string {
235 const convert = (pattern: string): string => {
236 switch (pattern) {
237 case "TaskLabel":
238 return task.label;
239 case "tasklabel":
240 return task.label.toLowerCase();
241 case "TASKLABEL":
242 return task.label.toUpperCase();
243 case "TaskID":
244 return task.id;
245 case "TASKID":
246 return task.id.toUpperCase();
247 case "TaskTitle":
248 return task.title;
249 case "ContestID":
250 return contest.id;
251 case "CONTESTID":
252 return contest.id.toUpperCase();
253 case "TailNumberOfContestID":
254 const result = /\d+$/.exec(contest.id);
255 return result === null ? "" : result[0];
256 case "ContestTitle":
257 return contest.title;
258 case "index0":
259 return index.toString();
260 case "index1":
261 return (index + 1).toString();
262 case "alphabet":
263 return convertNumber2Alphabet(index);
264 case "ALPHABET":
265 return convertNumber2Alphabet(index).toUpperCase();
266 }
267 throw new Error(
268 `pattern "{${pattern}} is not defined. use --help option to get more information."`
269 );
270 };
271 return format.replace(/{([a-zA-Z0-9]+)}/g, (_, p) => convert(p));
272}
273
274/**
275 * 数値をアルファベットに変換する

Callers 4

formatFunction · 0.90
addFunction · 0.90
installTaskTemplateFunction · 0.90
installTaskFunction · 0.85

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected