-
Notifications
You must be signed in to change notification settings - Fork 0
/
octopus-coffee.js
54 lines (49 loc) · 1.42 KB
/
octopus-coffee.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function() {
"use strict";
var gitDirs, octopus, rootDir;
rootDir = io.getRuntimeDirectories('plugins').shift();
gitDirs = rootDir.readDirectory(true).filter(function(dir) {
return dir.child(".git").exists();
});
octopus = {
version: "0.6.1",
directories: gitDirs,
execute: function(args) {
var cmd, dirs, fn;
dirs = args['-directories'] || args['-D'];
dirs = dirs ? this.directories.filter(function(dir) {
return dirs.indexOf(dir.leafName) >= 0;
}) : this.directories;
cmd = ("" + args) || "status";
fn = this._call.bind(this, cmd);
return dirs.forEach(fn);
},
_call: function(command, dir) {
var output, _cwd;
_cwd = io.cwd;
try {
io.cwd = dir.path;
output = io.system("git " + command);
} catch (error) {
output = error;
}
dactyl.echomsg("OCTOPUS: " + (dir.leafName.toUpperCase()) + " >> " + output);
return io.cwd = _cwd;
}
};
group.commands.add(["octopus", "git"], "Git Manager (version " + octopus.version + ")", function(args) {
return octopus.execute(args);
}, {
literal: 0,
options: [
{
names: ["-directories", "-D"],
description: "Select specific directories",
type: CommandOption.LIST,
completer: octopus.directories.map(function(dir) {
return [dir.leafName, dir.path];
})
}
]
});
}).call(this);