Skip to content

Commit

Permalink
chore: repl example
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Jun 14, 2022
1 parent e637c61 commit 3394413
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { command, program } from '../src/index.js'
let url: string | null = null

const app = program()

app
.add(
command('connect')
.description('Connect to a server')
Expand All @@ -28,6 +30,7 @@ const app = program()
.action(async ({ host, port, tls, protocol, timeout }) => {
url = `${protocol}${tls && 's'}://${host}:${port}`
console.log(`Connecting to ${url} (timeout set to ${timeout}s)...`)
app.options.prompt = `${host} > `
})
)
.add(
Expand All @@ -39,6 +42,7 @@ const app = program()
}

console.log(`Disconnecting from ${url}...`)
app.options.prompt = '> '
url = null
})
)
Expand Down

0 comments on commit 3394413

Please sign in to comment.