cli: merge with api-client

This commit is contained in:
Thomas Hobson 2021-03-13 16:08:35 +13:00
parent e5000917e8
commit a1536ffe56
No known key found for this signature in database
GPG key ID: 9F1FD9D87950DB6F
8 changed files with 28 additions and 102 deletions

View file

@ -1,4 +1,4 @@
const {PistonEngine} = require('piston-api-client');
const fetch = require('node-fetch');
const chalk = require('chalk');
exports.command = ['list']
@ -18,6 +18,12 @@ exports.handler = async function(argv){
const packages = await api.list_packages();
const packages = await fetch(argv['piston-url'] + '/packages')
.then(res=>res.json())
.then(res=>{if(res.data)return res.data; throw new Error(res.message)});
.then(res=>res.packages)
.catch(x=>x)
const pkg_msg = packages
.map(msg_format.color)