Skip to content

Commit

Permalink
Merge pull request #28 from freespek/igor/cli25
Browse files Browse the repository at this point in the history
add a simple CLI mock
  • Loading branch information
konnov authored Apr 16, 2024
2 parents 08e7089 + bb98f6a commit ff1ffbb
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 ff1ffbb

Please sign in to comment.