piston/cli/index.js

30 lines
625 B
JavaScript
Raw Normal View History

2021-03-13 01:19:05 +01:00
#!/usr/bin/env node
2021-06-13 08:41:01 +02:00
require('nocamel');
2021-03-13 04:44:33 +01:00
const axios = require('axios').default;
const axios_instance = argv => {
2021-03-13 04:44:33 +01:00
argv.axios = axios.create({
2021-05-07 21:35:27 +02:00
baseURL: argv['piston-url'],
headers: {
'Content-Type': 'application/json'
}
2021-03-13 04:44:33 +01:00
});
return argv;
};
2021-02-22 11:38:11 +01:00
require('yargs')(process.argv.slice(2))
.option('piston-url', {
alias: ['u'],
default: 'http://127.0.0.1:2000',
2021-02-22 11:38:11 +01:00
desc: 'Piston API URL',
string: true
})
2021-03-13 04:44:33 +01:00
.middleware(axios_instance)
.scriptName('piston')
2021-02-22 11:38:11 +01:00
.commandDir('commands')
.demandCommand()
.help()
.wrap(72)
2021-03-13 04:44:33 +01:00
.argv;