Verified Commit c65035f0 authored by Aral Balkan's avatar Aral Balkan
Browse files

Add version option to the command-line interface

parent 3a282b49
#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
var ansi = require('ansi-escape-sequences')
const httpsServer = require('../index.js')
const arguments = require('minimist')(process.argv.slice(2))
if (arguments._.length > 1 || arguments.help === true) {
if (arguments._.length > 2 || arguments.help === true) {
const usageFolderToServe = clr('folder-to-serve', 'green')
const usagePortOption = `${clr('--port', 'yellow')} ${clr('N', 'cyan')}`
const usageGlobalOption = `${clr('--global', 'yellow')} ${clr('you@your.site', 'cyan')}`
const usageVersionOption = `${clr('--version', 'yellow')}`
const usage = `
${clr('Usage:', 'underline')}
${clr('https-server', 'bold')} [${usageFolderToServe}] [${usagePortOption}] [${usageGlobalOption}]
${clr('https-server', 'bold')} [${usageFolderToServe}] [${usagePortOption}] [${usageGlobalOption}] [${usageVersionOption}]
${usageFolderToServe}\t\tPath to the folder to serve (optional; defaults to current folder).
${usagePortOption}\t\t\tThe port to start the server on (optional; defaults to 443).
${usageFolderToServe}\t\tPath to the folder to serve (defaults to current folder).
${usagePortOption}\t\t\tThe port to start the server on (defaults to 443).
${usageGlobalOption}\tUse globally-trusted certificates. The email address is required by Let’s Encrypt.
${usageVersionOption}\t\t\tDisplay the version.
`.replace(/\n$/, '').replace(/^\n/, '')
console.log(usage)
process.exit()
}
if (arguments.version !== undefined) {
const version = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8')).version
console.log(` https-server v${version}\n`)
process.exit()
}
// If no path is passed, serve the current folder.
// If there is a path, serve that.
let pathToServe = '.'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment