Skip to content

Commit

Permalink
add a simple CLI mock
Browse files Browse the repository at this point in the history
  • Loading branch information
konnov committed Apr 16, 2024
1 parent 08e7089 commit bb98f6a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
7 changes: 6 additions & 1 deletion solarkraft/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
);
{
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
);
38 changes: 37 additions & 1 deletion solarkraft/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,44 @@
* @license
* [Apache-2.0](https://github.com/freespek/solarkraft/blob/main/LICENSE)
*/

import yargs from 'yargs'
import { version } from './version.js'

// The default options present in every command
const defaultOpts = (yargs: any) =>
yargs.option('color', {
desc: 'color output',
type: 'boolean',
default: true,
})

// transaction extractor
const txExtractorCmd = {
command: ['txs'],
desc: 'extract transactions',
builder: (yargs: any) =>
defaultOpts(yargs)
.option('id', {
desc: 'Contract id',
type: 'string',
default: '123',
}),
handler: onTxExtractor,
}

// call the transaction extractor here
function onTxExtractor (args: any) {
console.log(`Mock TX Extractor(id: ${args.id})`)
}

function main() {
console.log('OK')
return yargs(process.argv.slice(2))
.command(txExtractorCmd)
.demandCommand(1)
.version(version)
.strict()
.parse()
}

main()

0 comments on commit bb98f6a

Please sign in to comment.