Skip to content

Commit

Permalink
commander options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginxo committed Oct 18, 2022
1 parent 6aacfcc commit 55b90d2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/smee.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
!/usr/bin/env node

const program = require('commander')
const { version } = require('../package.json')
Expand All @@ -12,17 +12,19 @@ program
.option('-t, --target <target>', 'Full URL (including protocol and path) of the target service the events will forwarded to. Default: http://127.0.0.1:PORT/PATH')
.option('-p, --port <n>', 'Local HTTP server port', process.env.PORT || 3000)
.option('-P, --path <path>', 'URL path to post proxied requests to`', '/')
.parse(process.argv)
.parse()

const options = program.opts()

let target
if (program.target) {
target = program.target
if (options.target) {
target = options.target
} else {
target = `http://127.0.0.1:${program.port}${program.path}`
target = `http://127.0.0.1:${options.port}${options.path}`
}

async function setup () {
let source = program.url
let source = options.url

if (!source) {
source = await Client.createChannel()
Expand All @@ -33,3 +35,4 @@ async function setup () {
}

setup()

0 comments on commit 55b90d2

Please sign in to comment.