This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/src/cli.ts
Jake Howard 251d46b43f
Use HSTS all the time, unless serving over HTTP
Not serving the HSTS header over HTTP is fairly bad
2018-01-17 20:31:12 +00:00

42 lines
1.2 KiB
TypeScript

import { docopt } from 'docopt';
import { Options } from './types';
const PKG = require('../package.json');
const ARG_DATA = `
${PKG.name}.
${PKG.description}
Usage:
tstatic <dir> [options]
tstatic -h | --help
tstatic --version
Options:
-h --help Show this screen.
--version Show version.
-p <port> --port=<port> Port to listen on.
-b <auth> --basic-auth=<auth> Enable basic-auth.
-i <ips> --ips=<ips> Allowed IP addresses.
-l --list-dir List Directory.
-s --allow-http Allow connection over HTTP.
--opbeat Enable Opbeat.
-o --open Open in browser after start.
`;
export default function getArgs() : Options {
const rawArgs = docopt(ARG_DATA, {
version: PKG.version,
help: true
});
return {
port: rawArgs['--port'] || process.env.PORT || 5000,
allowed_ips: rawArgs['--ips'] ? rawArgs['--ips'].split(',') : [],
basicAuth: rawArgs['--basic-auth'] ? rawArgs['--basic-auth'].split(':') : [],
dirList: rawArgs['--list-dir'],
serveDir: rawArgs['<dir>'],
opbeat: rawArgs['--opbeat'],
open: rawArgs['--open'],
allowHttp: rawArgs['--allow-http']
};
}