Skip to content

Commit

Permalink
feat: 🎸 Categorizing to organize command line tools
Browse files Browse the repository at this point in the history
  • Loading branch information
imfly committed Oct 3, 2020
1 parent fae996f commit 3d079d8
Show file tree
Hide file tree
Showing 50 changed files with 512 additions and 183 deletions.
1 change: 1 addition & 0 deletions packages/ddn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"shelljs": "^0.8.4",
"symbols": "^0.0.6",
"valid-url": "1.0.9",
"y18n": "^5.0.2",
"yargs": "^16.0.3"
},
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module.exports = {
command: 'maintain [command]',
desc: 'DDN maintain tools.',
command: 'account [command]',
aliases: ['A'],
desc: 'DDN account manage tools.',
builder: function (yargs) {
return yargs.commandDir('maintain')
return yargs.commandDir('account')
},

handler: function (argv) {
Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions packages/ddn/src/cmds/account/lock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { init, lock } from '../../plugins/api'

module.exports = {
command: 'lock',
aliases: 'L',
desc: 'Lock account to ban transfer ...',
builder: {
secret: {
alias: 'e',
describe: 'secret'
},
secondSecret: {
alias: 's',
describe: 'secondSecret'
},
height: {
alias: 'h',
describe: 'lock height'
}
},

handler: function (argv) {
init(argv)
lock(argv)
}
}
22 changes: 22 additions & 0 deletions packages/ddn/src/cmds/account/setSecondSecret.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { init, setSecondSecret } from '../../plugins/api'

module.exports = {
command: 'setSecondSecret',
aliases: 'SSS',
desc: 'Set second secret',
builder: {
secret: {
alias: 'e',
describe: 'secret'
},
secondSecret: {
alias: 's',
describe: 'secondSecret'
}
},

handler: function (argv) {
init(argv)
setSecondSecret(argv)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
command: 'blockchain [command]',
aliases: ['block', 'chain'],
desc: 'Manage blockchain',
command: 'block [command]',
aliases: ['B', 'block', 'chain'],
desc: 'Manage block tools',
builder: function (yargs) {
return yargs.commandDir('blockchain')
return yargs.commandDir('block')
},

handler: function (argv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { init, getBlockById } from '../../plugins/api'

module.exports = {
command: 'getBlockById [id]',
aliases: 'BById',
aliases: 'GBBI',
desc: 'Get block by id',
builder: {},

Expand Down
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/block/getBlockPayloadHash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, getBlockPayloadHash } from '../../plugins/api'

module.exports = {
command: 'getBlockPayloadHash',
aliases: 'GBI',
desc: 'Get block payload hash',
builder: {
file: {
alias: 'f',
describe: 'block file'
}
},

handler: function (argv) {
init(argv)
getBlockPayloadHash(argv)
}
}
File renamed without changes.
13 changes: 13 additions & 0 deletions packages/ddn/src/cmds/block/getFullBlockByHeight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { init, getFullBlockByHeight } from '../../plugins/api'

module.exports = {
command: 'getFullBlockByHeight [height]',
aliases: 'GFBBH',
desc: 'Get full block by block height',
builder: {},

handler: function (argv) {
init(argv)
getFullBlockByHeight(argv.height)
}
}
13 changes: 13 additions & 0 deletions packages/ddn/src/cmds/block/getFullBlockById.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { init, getFullBlockById } from '../../plugins/api'

module.exports = {
command: 'getFullBlockById [id]',
aliases: 'GFBBI',
desc: 'Get full block by block id',
builder: {},

handler: function (argv) {
init(argv)
getFullBlockById(argv.id)
}
}
File renamed without changes.
5 changes: 4 additions & 1 deletion packages/ddn/src/cmds/dapp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const y18n = require('y18n')
const __ = y18n().__

module.exports = {
command: 'dapp [command]',
desc: 'Manage dapps',
Expand All @@ -6,6 +9,6 @@ module.exports = {
},

handler: function (argv) {
console.log('Hi, please select a command, e.g: new, install, --help')
console.log(__('Hi, please select a command, e.g: new, install, --help'))
}
}
12 changes: 12 additions & 0 deletions packages/ddn/src/cmds/delegate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
command: 'delegate [command]',
aliases: ['D'],
desc: 'DDN delegate manage tools.',
builder: function (yargs) {
return yargs.commandDir('delegate')
},

handler: function (argv) {
console.log('Hi, please select a command, e.g: peerStat, --help')
}
}
26 changes: 26 additions & 0 deletions packages/ddn/src/cmds/delegate/downvote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { init, downvote } from '../../plugins/api'

module.exports = {
command: 'downvote',
aliases: 'DV',
desc: 'Cancel vote for delegates',
builder: {
secret: {
alias: 'e',
describe: 'secret'
},
secondSecret: {
alias: 's',
describe: 'secondSecret'
},
publicKeys: {
alias: 'p',
describe: 'publicKey list'
}
},

handler: function (argv) {
init(argv)
downvote(argv)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
},
state: {
alias: 't',
describe: 'State'
describe: 'State',
choices: [0, 1, 2]
},
version: {
alias: 'v',
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/delegate/listdiffvotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, listdiffvotes } from '../../plugins/api'

module.exports = {
command: 'listdiffvotes',
aliases: 'LDV',
desc: 'List all you voted but doesn`t vote you and voted you but you don`t vote.',
builder: {
username: {
alias: 'u',
describe: 'username'
}
},

handler: function (argv) {
init(argv)
listdiffvotes(argv)
}
}
File renamed without changes.
26 changes: 26 additions & 0 deletions packages/ddn/src/cmds/delegate/registerDelegate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { init, registerDelegate } from '../../plugins/api'

module.exports = {
command: 'registerDelegate',
aliases: 'RD',
desc: 'Register delegate',
builder: {
secret: {
alias: 'e',
describe: 'secret'
},
secondSecret: {
alias: 's',
describe: 'secondSecret'
},
username: {
alias: 'u',
describe: 'username'
}
},

handler: function (argv) {
init(argv)
registerDelegate(argv)
}
}
26 changes: 26 additions & 0 deletions packages/ddn/src/cmds/delegate/upvote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { init, upvote } from '../../plugins/api'

module.exports = {
command: 'upvote',
aliases: 'UV',
desc: 'Vote for delegates',
builder: {
secret: {
alias: 'e',
describe: 'secret'
},
secondSecret: {
alias: 's',
describe: 'secondSecret'
},
publicKeys: {
alias: 'p',
describe: 'publicKey list'
}
},

handler: function (argv) {
init(argv)
upvote(argv)
}
}
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/dev/getBlockBytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, getBlockBytes } from '../../plugins/api'

module.exports = {
command: 'getBlockBytes',
aliases: 'GBB',
desc: 'Get block bytes',
builder: {
file: {
alias: 'f',
describe: 'block file'
}
},

handler: function (argv) {
init(argv)
getBlockBytes(argv)
}
}
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/dev/getBlockId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, getBlockId } from '../../plugins/api'

module.exports = {
command: 'getBlockId',
aliases: 'GBI',
desc: 'Get block id',
builder: {
file: {
alias: 'f',
describe: 'block file'
}
},

handler: function (argv) {
init(argv)
getBlockId(argv)
}
}
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/dev/getTransactionBytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, getTransactionBytes } from '../../plugins/api'

module.exports = {
command: 'getTransactionBytes',
aliases: 'GTB',
desc: 'Get transaction bytes',
builder: {
file: {
alias: 'f',
describe: 'transaction file'
}
},

handler: function (argv) {
init(argv)
getTransactionBytes(argv)
}
}
18 changes: 18 additions & 0 deletions packages/ddn/src/cmds/dev/getTransactionId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { init, getTransactionId } from '../../plugins/api'

module.exports = {
command: 'getTransactionId',
aliases: 'GTI',
desc: 'Get transaction id',
builder: {
file: {
alias: 'f',
describe: 'transaction file'
}
},

handler: function (argv) {
init(argv)
getTransactionId(argv)
}
}
26 changes: 26 additions & 0 deletions packages/ddn/src/cmds/dev/verifyBytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { init, verifyBytes } from '../../plugins/api'

module.exports = {
command: 'verifyBytes',
aliases: 'VB',
desc: 'Verify bytes/signature/publickey',
builder: {
bytes: {
alias: 'b',
describe: 'transaction or block bytes'
},
signature: {
alias: 's',
describe: 'transaction or block signature'
},
publicKey: {
alias: 'p',
describe: 'signer public key'
}
},

handler: function (argv) {
init(argv)
verifyBytes(argv)
}
}
12 changes: 12 additions & 0 deletions packages/ddn/src/cmds/transaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
command: 'transaction [command]',
aliases: ['T', 'trs'],
desc: 'Manage transaction tools.',
builder: function (yargs) {
return yargs.commandDir('transaction')
},

handler: function (argv) {
console.log('Hi, please select a command, e.g: getTransaction, --help')
}
}
Loading

0 comments on commit 3d079d8

Please sign in to comment.