Skip to content

Commit 3752ff1

Browse files
author
Alessandro Sangalli
committed
feat: timer
1 parent 63ed9b5 commit 3752ff1

4 files changed

Lines changed: 46 additions & 19 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ Mob VSCode GUI is a wrapper of https://mob.sh/.
44

55
## Features
66

7-
- Use Mob Start to create or enter in the mob temporary branch (you turn).
8-
- Use Mob Next to handover to the next person.
9-
- Use Mob Done to commit your mob session work.
10-
- Use Mob Reset to delete your local and remote WIP branch.
7+
- Mob Start to create or enter in the mob temporary branch (you turn).
8+
- Mob Next to handover to the next person.
9+
- Mob Done to commit your mob session work.
10+
- Mob Reset to delete your local and remote WIP branch.
11+
- Mob Timer to create a timer (in minutes), a pop-up will appear when the time is up.
1112

1213
After Mob Done, do git commit -m "YOUR MESSAGE" and git push.
1314

src/commands.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as childProcess from "child_process";
22
import { ExecException } from "child_process";
33
import * as vscode from "vscode";
44
import { commandErrorHandler } from "./command-error-handler";
5+
import { timerInputValidator } from "./validators/time-input-validator";
56
var commandExists = require("command-exists");
67

78
export const commands = [
@@ -18,21 +19,7 @@ export const commands = [
1819
const timeInput = vscode.window.showInputBox({
1920
title: "How much time?",
2021
placeHolder: "Enter to ignore",
21-
validateInput: (input) => {
22-
if (input === "") {
23-
return null;
24-
}
25-
26-
if (!/^\d+$/.test(input)) {
27-
return "Please enter a number";
28-
}
29-
30-
if (Number(input) < 1) {
31-
return "Please enter a number greater than 0";
32-
}
33-
34-
return null;
35-
},
22+
validateInput: (input) => timerInputValidator(input),
3623
});
3724

3825
timeInput.then((input) => {
@@ -87,6 +74,25 @@ export const commands = [
8774
}
8875
});
8976
}),
77+
vscode.commands.registerCommand("mob-vscode-gui.timer", () => {
78+
const timeInput = vscode.window.showInputBox({
79+
title: "How much time?",
80+
placeHolder: "Enter to ignore",
81+
validateInput: (input) => timerInputValidator(input),
82+
});
83+
84+
timeInput.then((input) => {
85+
let command = "mob timer";
86+
const timer = Number(input);
87+
88+
if (timer > 0) {
89+
command += ` ${timer}`;
90+
}
91+
92+
const expectedMessage = ["Happy collaborating!"];
93+
exec(command, expectedMessage);
94+
});
95+
}),
9096
];
9197

9298
function exec(command: string, expectedMessage: string[]) {

src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ function createMobStatusBarItem(context: vscode.ExtensionContext) {
6363
description: "Delete local and remote WIP branch",
6464
command: "mob-vscode-gui.reset",
6565
},
66+
{
67+
label: "Timer",
68+
description: "Set timer (in minutes)",
69+
command: "mob-vscode-gui.timer",
70+
},
6671
])
6772
.then((option) => {
6873
if (option) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export function timerInputValidator(input: string): string | null {
2+
if (input === "") {
3+
return null;
4+
}
5+
6+
if (!/^\d+$/.test(input)) {
7+
return "Please enter a number";
8+
}
9+
10+
if (Number(input) < 1) {
11+
return "Please enter a number greater than 0";
12+
}
13+
14+
return null;
15+
}

0 commit comments

Comments
 (0)