--register and --unregister.
This commit is contained in:
parent
e762002560
commit
3981c772a2
@ -83,8 +83,33 @@ var help = exports.help = wrap(multiline.stripIndent(function () {/*
|
||||
exports.version = wrap('xo-cli v'+ require('../package').version);
|
||||
|
||||
exports.register = function (args) {
|
||||
var xo;
|
||||
return Promise.try(function () {
|
||||
xo = new Xo(args[0]);
|
||||
|
||||
return xo.call('session.signInWithPassword', {
|
||||
email: args[1],
|
||||
password: args[2],
|
||||
});
|
||||
}).then(function (user) {
|
||||
console.log('Successfully logged with', user.email);
|
||||
|
||||
return xo.call('token.create');
|
||||
}).then(function (token) {
|
||||
return config.set({
|
||||
server: args[0],
|
||||
token: token,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.unregister = function () {
|
||||
return config.unset([
|
||||
'server',
|
||||
'token',
|
||||
]);
|
||||
}
|
||||
|
||||
exports.listCommands = function (args) {
|
||||
return connect().then(function (xo) {
|
||||
return xo.call('system.getMethodsInfo');
|
||||
|
@ -46,3 +46,13 @@ exports.set = function (data) {
|
||||
return save(_.extend(config, data));
|
||||
});
|
||||
};
|
||||
|
||||
exports.unset = function (paths) {
|
||||
return load().then(function (config) {
|
||||
var l33tConfig = l33t(config);
|
||||
[].concat(paths).forEach(function (path) {
|
||||
l33tConfig.purge(path, true);
|
||||
});
|
||||
return save(config);
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user