Skip to content

add leetcode.signinByCookie but simple change #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename cookie in to Sign in (by cookie)
  • Loading branch information
yihong0618 committed Dec 4, 2019
commit 8d24d57a41df7b08d5635df31ed3c072b78b2250
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

- You can also use the following command to sign in/cookie in/out:
- **LeetCode: Sign in**
- **LeetCode: Cookie in**
- **LeetCode: Sign in (by cookie)**
- **LeetCode: Sign out**

---
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
"onCommand:leetcode.testSolution",
"onCommand:leetcode.submitSolution",
"onCommand:leetcode.switchDefaultLanguage",
"onCommand:leetcode.cookieIn",
"onCommand:leetcode.signinByCookie",
"onView:leetCodeExplorer"
],
"main": "./out/src/extension",
"contributes": {
"commands": [
{
"command": "leetcode.cookieIn",
"title": "Cookie In",
"command": "leetcode.signinByCookie",
"title": "Sign In By Cookie",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: By should be lower case since it's a preposition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will change it right now

"category": "LeetCode"
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
vscode.commands.registerCommand("leetcode.deleteCache", () => cache.deleteCache()),
vscode.commands.registerCommand("leetcode.toggleLeetCodeCn", () => plugin.switchEndpoint()),
vscode.commands.registerCommand("leetcode.signin", () => leetCodeManager.signIn()),
vscode.commands.registerCommand("leetcode.cookieIn", () => leetCodeManager.signIn(true)),
vscode.commands.registerCommand("leetcode.signinByCookie", () => leetCodeManager.signIn(true)),
vscode.commands.registerCommand("leetcode.signout", () => leetCodeManager.signOut()),
vscode.commands.registerCommand("leetcode.manageSessions", () => session.manageSessions()),
vscode.commands.registerCommand("leetcode.previewProblem", (node: LeetCodeNode) => show.previewProblem(node)),
Expand Down
12 changes: 6 additions & 6 deletions src/leetCodeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class LeetCodeManager extends EventEmitter {
}
}

public async signIn(isCookieIn: boolean = false): Promise<void> {
public async signIn(isByCookie: boolean = false): Promise<void> {
const loginArg: string = "-l";
const cookieInArg: string = "-c";
const commandArg: string = isCookieIn ? cookieInArg : loginArg;
const inMessage: string = isCookieIn ? "cookie in" : "sign in";
const cookieArg: string = "-c";
const commandArg: string = isByCookie ? cookieArg : loginArg;
const inMessage: string = isByCookie ? "sign in by cookie" : "sign in";
try {
const userName: string | undefined = await new Promise(async (resolve: (res: string | undefined) => void, reject: (e: Error) => void): Promise<void> => {
let result: string = "";
Expand Down Expand Up @@ -71,9 +71,9 @@ class LeetCodeManager extends EventEmitter {
}
childProc.stdin.write(`${name}\n`);
const pwd: string | undefined = await vscode.window.showInputBox({
prompt: isCookieIn ? "Enter cookie" : "Enter password.",
prompt: isByCookie ? "Enter cookie" : "Enter password.",
password: true,
validateInput: (s: string): string | undefined => s ? undefined : isCookieIn ? "Cookie must not be empty" : "Password must not be empty",
validateInput: (s: string): string | undefined => s ? undefined : isByCookie ? "Cookie must not be empty" : "Password must not be empty",
});
if (!pwd) {
childProc.kill();
Expand Down