@@ -2,6 +2,7 @@ import * as childProcess from "child_process";
22import { ExecException } from "child_process" ;
33import * as vscode from "vscode" ;
44import { commandErrorHandler } from "./command-error-handler" ;
5+ import { timerInputValidator } from "./validators/time-input-validator" ;
56var commandExists = require ( "command-exists" ) ;
67
78export 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
9298function exec ( command : string , expectedMessage : string [ ] ) {
0 commit comments