commands.ts 2.2 KB
Newer Older
J
Joao Moreno 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

J
Joao Moreno 已提交
8
import { commands, Disposable, SCMResourceGroup, SCMResource } from 'vscode';
9
import { Model } from './model';
J
Joao Moreno 已提交
10 11
import { log } from './util';

J
Joao Moreno 已提交
12 13 14
function refresh(model: Model): void {
	log('refresh');
	model.update();
J
Joao Moreno 已提交
15
}
J
Joao Moreno 已提交
16

J
Joao Moreno 已提交
17
function openChange(model: Model, resource: SCMResource): void {
J
Joao Moreno 已提交
18
	log('open change', resource);
J
Joao Moreno 已提交
19 20
}

J
Joao Moreno 已提交
21
function openFile(model: Model, resource: SCMResource): void {
J
Joao Moreno 已提交
22
	log('open file', resource);
J
Joao Moreno 已提交
23 24
}

J
Joao Moreno 已提交
25
function stage(model: Model, resource: SCMResource): void {
J
Joao Moreno 已提交
26 27 28
	log('stage', resource);
}

J
Joao Moreno 已提交
29
function stageAll(model: Model, resourceGroup: SCMResourceGroup): void {
J
Joao Moreno 已提交
30
	log('stageAll', resourceGroup);
J
Joao Moreno 已提交
31 32
}

J
Joao Moreno 已提交
33
function unstage(model: Model, resource: SCMResource): void {
J
Joao Moreno 已提交
34 35 36
	log('unstage', resource);
}

J
Joao Moreno 已提交
37
function unstageAll(model: Model, resourceGroup: SCMResourceGroup): void {
J
Joao Moreno 已提交
38
	log('unstageAll', resourceGroup);
J
Joao Moreno 已提交
39 40
}

J
Joao Moreno 已提交
41
function clean(model: Model, resource: SCMResource): void {
J
Joao Moreno 已提交
42 43 44
	log('clean', resource);
}

J
Joao Moreno 已提交
45
function cleanAll(model: Model, resourceGroup: SCMResourceGroup): void {
J
Joao Moreno 已提交
46 47
	log('clean all', resourceGroup);
}
J
Joao Moreno 已提交
48

J
Joao Moreno 已提交
49 50 51 52
function bind(command: (model: Model, ...args: any[]) => any, model: Model): (...args: any[]) => any {
	return command.bind(null, model);
}

53
export function registerCommands(model: Model): Disposable {
J
Joao Moreno 已提交
54
	const disposables = [
J
Joao Moreno 已提交
55 56 57 58 59 60 61 62 63
		commands.registerCommand('git.refresh', bind(refresh, model)),
		commands.registerCommand('git.openChange', bind(openChange, model)),
		commands.registerCommand('git.openFile', bind(openFile, model)),
		commands.registerCommand('git.stage', bind(stage, model)),
		commands.registerCommand('git.stageAll', bind(stageAll, model)),
		commands.registerCommand('git.unstage', bind(unstage, model)),
		commands.registerCommand('git.unstageAll', bind(unstageAll, model)),
		commands.registerCommand('git.clean', bind(clean, model)),
		commands.registerCommand('git.cleanAll', bind(cleanAll, model)),
J
Joao Moreno 已提交
64 65 66
	];

	return Disposable.from(...disposables);
J
Joao Moreno 已提交
67
}