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