A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

61 lines
1.5 KiB

  1. /*
  2. * Copyright © 2020-2021 Musing Studio LLC.
  3. *
  4. * This file is part of WriteFreely.
  5. *
  6. * WriteFreely is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License, included
  8. * in the LICENSE file in this source code package.
  9. */
  10. package main
  11. import (
  12. "github.com/urfave/cli/v2"
  13. "github.com/writefreely/writefreely"
  14. )
  15. var (
  16. cmdConfig cli.Command = cli.Command{
  17. Name: "config",
  18. Usage: "config management tools",
  19. Subcommands: []*cli.Command{
  20. &cmdConfigGenerate,
  21. &cmdConfigInteractive,
  22. },
  23. }
  24. cmdConfigGenerate cli.Command = cli.Command{
  25. Name: "generate",
  26. Aliases: []string{"gen"},
  27. Usage: "Generate a basic configuration",
  28. Action: genConfigAction,
  29. }
  30. cmdConfigInteractive cli.Command = cli.Command{
  31. Name: "start",
  32. Usage: "Interactive configuration process",
  33. Action: interactiveConfigAction,
  34. Flags: []cli.Flag{
  35. &cli.StringFlag{
  36. Name: "sections",
  37. Value: "server db app",
  38. Usage: "Which sections of the configuration to go through\n" +
  39. "valid values of sections flag are any combination of 'server', 'db' and 'app' \n" +
  40. "example: writefreely config start --sections \"db app\"",
  41. },
  42. },
  43. }
  44. )
  45. func genConfigAction(c *cli.Context) error {
  46. app := writefreely.NewApp(c.String("c"))
  47. return writefreely.CreateConfig(app)
  48. }
  49. func interactiveConfigAction(c *cli.Context) error {
  50. app := writefreely.NewApp(c.String("c"))
  51. writefreely.DoConfig(app, c.String("sections"))
  52. return nil
  53. }