cli.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. const yargs = require("yargs");
  3. const _ = require("lodash");
  4. /**
  5. * @param {object} presets
  6. * @param {string} defaultConfigFile
  7. */
  8. module.exports = (presets, defaultConfigFile) =>
  9. yargs
  10. .scriptName("oasis")
  11. .env("OASIS")
  12. .help("h")
  13. .alias("h", "help")
  14. .usage("Usage: $0 [options]")
  15. .options("open", {
  16. describe:
  17. "Automatically open app in web browser. Use --no-open to disable.",
  18. default: _.get(presets, "open", true),
  19. type: "boolean",
  20. })
  21. .options("offline", {
  22. describe:
  23. "Don't try to connect to scuttlebutt peers or pubs. This can be changed on the 'settings' page while Oasis is running.",
  24. default: _.get(presets, "offline", false),
  25. type: "boolean",
  26. })
  27. .options("host", {
  28. describe: "Hostname for web app to listen on",
  29. default: _.get(presets, "host", "localhost"),
  30. type: "string",
  31. })
  32. .options("allow-host", {
  33. describe:
  34. "Extra hostname to be whitelisted (useful when running behind a proxy)",
  35. default: _.get(presets, "allow-host", null),
  36. type: "string",
  37. })
  38. .options("port", {
  39. describe: "Port for web app to listen on",
  40. default: _.get(presets, "port", 3000),
  41. type: "number",
  42. })
  43. .options("public", {
  44. describe:
  45. "Assume Oasis is being hosted publicly, disable HTTP POST and redact messages from people who haven't given consent for public web hosting.",
  46. default: _.get(presets, "public", false),
  47. type: "boolean",
  48. })
  49. .options("debug", {
  50. describe: "Use verbose output for debugging",
  51. default: _.get(presets, "debug", false),
  52. type: "boolean",
  53. })
  54. .options("theme", {
  55. describe: "The theme to use, if a theme hasn't been set in the cookies",
  56. default: _.get(presets, "theme", "classic-light"),
  57. type: "string",
  58. })
  59. .epilog(`The defaults can be configured in ${defaultConfigFile}.`).argv;