Skip to content

Commit

Permalink
feat(example): add node example
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenye committed Dec 26, 2024
1 parent 2e0b32c commit c14146a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
3 changes: 2 additions & 1 deletion cli
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

./example/cli.ts "$@"
./example/bun.js "$@"
# ./example/node.js "$@"

6 changes: 6 additions & 0 deletions example/bun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bun

import { Argument, program } from '#root/src'
import main from './cli'

main({ program, Argument })
21 changes: 21 additions & 0 deletions example/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default async function main({ program, Argument }) {
program.name('cli').enableCompletion()

program
.command('cmd1')
.addArgument(new Argument('[arg1]').choices(['arg1', 'arg2', 'arg3']))
.option('--option1')
.option('--option2')
.action((arg1, options) => {
console.log('args:', [arg1])
console.log('options:', options)
})

program.command('cmd2')

program.command('cmd3')

await program.installCompletion()

program.parse()
}
23 changes: 0 additions & 23 deletions example/cli.ts

This file was deleted.

6 changes: 6 additions & 0 deletions example/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

import { Argument, program } from '../build/index.js'
import main from './cli.js'

main({ program, Argument })

0 comments on commit c14146a

Please sign in to comment.