28 lines
884 B
JavaScript
Executable File
28 lines
884 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
const App = require('../index.js')
|
|
const sig = fn =>
|
|
fn.toString().split('\n')[0].replace(/^async /, '').replace(/ \{/, '')
|
|
|
|
const methods = App.prototype
|
|
// poor man's CLI
|
|
const [,, method, ...args] = process.argv
|
|
if (method in methods) {
|
|
if (args.length < methods[method].length) {
|
|
console.error("not enough arguments for method", sig(methods[method]))
|
|
} else {
|
|
App.authAll().then((auth) => {
|
|
const app = new App(auth)
|
|
app[method](...args)
|
|
})
|
|
}
|
|
} else {
|
|
if (method && method != 'help') console.log("unknown subcall", method)
|
|
console.log("valid methods:")
|
|
for(const realMethod of Object.getOwnPropertyNames(methods)) {
|
|
if (realMethod == 'constructor') continue
|
|
if (methods[realMethod])
|
|
console.log(" ", sig(methods[realMethod]))
|
|
}
|
|
process.exit(1)
|
|
}
|