Skip to content

Commit

Permalink
added tons of CLI code, all untested
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorJTClarke committed Apr 10, 2021
1 parent b10461d commit 76dc8be
Show file tree
Hide file tree
Showing 47 changed files with 239 additions and 2,194 deletions.
6 changes: 3 additions & 3 deletions cli/bin/near → bin/crond
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ require('v8flags')((e, flags) => {
throw e;
}
flaggedRespawn(
flags.concat(['--experimental_repl_await']),
process.argv.indexOf('repl') == -1 ? process.argv : process.argv.concat(['--experimental-repl-await']),
flags,
process.argv,
ready => {
if (ready) {
// Need to filter out '--no-respawning' to avoid yargs complaining about it
process.argv = process.argv.filter(arg => arg != '--no-respawning');
require('./near-cli.js');
require('./crond.js');
}
});
})
97 changes: 97 additions & 0 deletions bin/crond.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
require('dotenv').config()
const chalk = require('chalk')
const yargs = require('yargs')
import { agentFunction } from '../src/actions'

const chalk = require('chalk');

const registerAgent = {
command: 'register <accountId>',
desc: 'Add your agent to cron known agents',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to add',
type: 'string',
required: true
})
.option('payableAccountId', {
desc: 'Account that receives reward payouts',
type: 'string',
required: false
}),
handler: async function (options) {
await agentFunction('register_agent', options);
}
};

const updateAgent = {
command: 'update <accountId>',
desc: 'Update your agent to cron known agents',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to add',
type: 'string',
required: true
})
.option('payableAccountId', {
desc: 'Account that receives reward payouts',
type: 'string',
required: false
}),
handler: async function (options) {
await agentFunction('update_agent', options);
}
};

const unregisterAgent = {
command: 'unregister <accountId>',
desc: 'Account to remove from list of active agents.',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account to remove.',
type: 'string',
required: true
}),
handler: async function (options) {
await agentFunction('unregister_agent', options)
}
};

const withdrawBalance = {
command: 'update <accountId>',
desc: 'Withdraw all rewards earned for this account',
builder: (yargs) => yargs
.option('accountId', {
desc: 'Account that earned rewards.',
type: 'string',
required: true
}),
handler: async function (options) {
await agentFunction('withdraw_task_balance', options);
}
};

let config = require('../src/config').getConfig(process.env.NODE_ENV || 'development');
yargs // eslint-disable-line
.strict()
.middleware(require('../cli/check-version'))
.scriptName('crond')
.option('verbose', {
desc: 'Prints out verbose output',
type: 'boolean',
alias: 'v',
default: false
})
.middleware(require('../src/print-options'))
.command(registerAgent)
.command(updateAgent)
.command(unregisterAgent)
.command(withdrawBalance)
.config(config)
.showHelpOnFail(true)
.recommendCommands()
.demandCommand(1, chalk`Pass {bold --help} to see all available commands and options.`)
.usage(chalk`Usage: {bold $0 <command> [options]}`)
.epilogue(chalk`More info: {bold https://cron.cat}`)
.wrap(null)
.argv;
267 changes: 0 additions & 267 deletions cli/bin/near-cli.js

This file was deleted.

Loading

0 comments on commit 76dc8be

Please sign in to comment.