-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tons of CLI code, all untested
- Loading branch information
1 parent
b10461d
commit 76dc8be
Showing
47 changed files
with
239 additions
and
2,194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.