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

Function formatContestDirname

src/project.ts:214–232  ·  view source on GitHub ↗
(format: string, contest: Contest)

Source from the content-addressed store, hash-verified

212}
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
234export function formatTaskDirname(format: string, task: Task, index: number, contest: Contest): string {
235 const convert = (pattern: string): string => {

Callers 3

formatFunction · 0.90
installContestTemplateFunction · 0.90
initFunction · 0.85

Calls 1

convertFunction · 0.85

Tested by

no test coverage detected