()
| 8 | import { DialogOptions, DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils"; |
| 9 | |
| 10 | export async function getSessionList(): Promise<ISession[]> { |
| 11 | const signInStatus: string | undefined = leetCodeManager.getUser(); |
| 12 | if (!signInStatus) { |
| 13 | promptForSignIn(); |
| 14 | return []; |
| 15 | } |
| 16 | const result: string = await leetCodeExecutor.listSessions(); |
| 17 | const lines: string[] = result.split("\n"); |
| 18 | const sessions: ISession[] = []; |
| 19 | const reg: RegExp = /(.?)\s*(\d+)\s+(.*)\s+(\d+ \(\s*\d+\.\d+ %\))\s+(\d+ \(\s*\d+\.\d+ %\))/; |
| 20 | for (const line of lines) { |
| 21 | const match: RegExpMatchArray | null = line.match(reg); |
| 22 | if (match && match.length === 6) { |
| 23 | sessions.push({ |
| 24 | active: !!(match[1].trim()), |
| 25 | id: match[2].trim(), |
| 26 | name: match[3].trim(), |
| 27 | acQuestions: match[4].trim(), |
| 28 | acSubmits: match[5].trim(), |
| 29 | }); |
| 30 | } |
| 31 | } |
| 32 | return sessions; |
| 33 | } |
| 34 | |
| 35 | export async function manageSessions(): Promise<void> { |
| 36 | const choice: IQuickItemEx<ISession | string> | undefined = await vscode.window.showQuickPick(parseSessionsToPicks(true /* includeOperation */)); |
no test coverage detected