import * as vscode from 'vscode' ; export interface Command { readonly id : string ; execute ( ... args ) : void ; } export class CommandManager { private readonly _commands = new Map < string , vscode . Disposable > ( ) ; public dispose ( ) { for ( const registration of this . _commands . values ( ) ) { registration . dispose ( ) ; } this . _commands . clear ( ) ; } public register < T extends Command > ( command ) { this . registerCommand ( command . id , command . execute , command ) ; return command ; } private registerCommand ( id , impl , thisArg ? ) { if ( this . _commands . has ( id ) ) { return ; } this . _commands . set ( id , vscode . commands . registerCommand ( id , impl , thisArg ) ) ; } }