piston/cli/commands/ppman_commands/list.js

26 lines
645 B
JavaScript
Raw Normal View History

2021-02-27 07:30:11 +01:00
const chalk = require('chalk');
exports.command = ['list'];
exports.aliases = ['l'];
exports.describe = 'Lists all available packages';
2021-02-27 07:30:11 +01:00
const msg_format = {
2021-10-08 15:16:57 +02:00
color: p =>
`${chalk[p.installed ? 'green' : 'red']('•')} ${p.language} ${
p.language_version
}`,
monochrome: p =>
`${p.language} ${p.language_version} ${
p.installed ? '(INSTALLED)' : ''
}`,
json: JSON.stringify,
};
2021-04-23 01:43:21 +02:00
exports.handler = async ({ axios }) => {
const packages = await axios.get('/api/v2/packages');
2021-03-05 07:40:47 +01:00
2021-10-08 15:16:57 +02:00
const pkg_msg = packages.data.map(msg_format.color).join('\n');
2021-02-27 07:30:11 +01:00
console.log(pkg_msg);
2021-10-08 15:16:57 +02:00
};