Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/utils/lib/narwhal/tusk/platform.js
blob: 48ac58c61adb6a22382e72706d6dc19b404bc570 (plain)
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

var os = require('os');
var util = require('util');
var tusk = require('../tusk');
var args = require('args');

var parser = exports.parser = new args.Parser();

parser.help('selects a platform for the current "sea"');

parser.arg('platform').optional();

parser.action(function (options) {
    var self = this;
    var directory = tusk.getDirectory();
    var platformsDirectory = directory.join('platforms');
    if (options.args.length == 0) {
        platformsDirectory.list().forEach(function (platformName) {
            self.print(platformName);
        });
    } else {
        var platform = options.args.shift();
        if (!util.has(platformsDirectory.list(), platform))
            throw new Error("No such platform");
        var narwhalConf = directory.join('narwhal.conf');
        narwhalConf.write(
            'NARWHAL_DEFAULT_PLATFORM=' +
            os.enquote(platform)
        );
    }
});