2021-03-13 01:19:05 +01:00
|
|
|
#!/usr/bin/env node
|
2021-03-13 04:44:33 +01:00
|
|
|
|
|
|
|
const axios = require('axios').default;
|
|
|
|
|
2021-05-07 21:22:25 +02:00
|
|
|
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'],
|
2021-03-28 21:01:46 +02:00
|
|
|
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)
|
2021-05-07 21:22:25 +02:00
|
|
|
.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;
|