<commit_before>/*
  Copyright (C) 2017 <NAME>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package main

import (
	"os"

	"github.com/chavamee/syndication/admin"
	"github.com/chavamee/syndication/config"
	"github.com/chavamee/syndication/database"
	"github.com/chavamee/syndication/server"
	"github.com/chavamee/syndication/sync"
	"github.com/fatih/color"
	"github.com/urfave/cli"
)

func main() {
	app := cli.NewApp()

	app.Name = "syndication"
	app.Usage = "A Super Simple RSS server"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "config",
			Usage: "Path to configuration file to use",
		},
		cli.StringFlag{
			Name:  "socket",
			Usage: "Path to admin socket",
		},
		cli.BoolFlag{
			Name:  "admin",
			Usage: "Enable/Disable admin",
		},
		cli.BoolFlag{
			Name:  "sync",
			Usage: "Enable/Disable sync",
		},
	}

	app.Action = func(c *cli.Context) error {
		var conf config.Config
		var err error

		if c.String("config") == "" {
			conf = config.DefaultConfig
		} else {
			conf, err = config.NewConfig(c.String("config"))
			if err != nil {
				color.Red(err.Error())
				return err
			}
		}

		db, err := database.NewDB(conf.Database.Type, conf.Database.Connection)
		if err != nil {
			return err
		}
		sync := sync.NewSync(db)
		sync.Start()

		admin, err := admin.NewAdmin(db, conf.Admin.SocketPath)
		if err != nil {
			return err
		}
		admin.Start()

		defer admin.Stop(true)

		server := server.NewServer(db, sync, conf.Server)
		server.Start()

		return err
	}

	app.Run(os.Args)
}<commit_msg>Corrected configuration flag and startup<commit_after>/*
  Copyright (C) 2017 <NAME>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package main

import (
	"os"

	"github.com/chavamee/syndication/admin"
	"github.com/chavamee/syndication/config"
	"github.com/chavamee/syndication/database"
	"github.com/chavamee/syndication/server"
	"github.com/chavamee/syndication/sync"
	"github.com/fatih/color"
	"github.com/urfave/cli"
)

func findSystemConfig() (config.Config, error) {
	if _, err := os.Stat(config.SystemConfigPath); err != nil {
		return config.Config{}, err
	}

	conf, err := config.NewConfig(config.SystemConfigPath)
	if err != nil {
		return config.Config{}, err
	}

	return conf, nil
}

func startApp(c *cli.Context) error {
	var conf config.Config
	var err error

	if c.String("config") == "" {
		conf, err = findSystemConfig()
		if err != nil {
			color.Red(err.Error())
			return err
		}
	} else {
		conf, err = config.NewConfig(c.String("config"))
		if err != nil {
			color.Red(err.Error())
			return err
		}
	}

	db, err := database.NewDB(conf.Database.Type, conf.Database.Connection)
	if err != nil {
		return err
	}
	sync := sync.NewSync(db)
	sync.Start()

	admin, err := admin.NewAdmin(db, conf.Admin.SocketPath)
	if err != nil {
		return err
	}
	admin.Start()

	defer admin.Stop(true)

	server := server.NewServer(db, sync, conf.Server)
	if err = server.Start(); err != nil {
		color.Red(err.Error())
	}

	return err
}

func main() {
	app := cli.NewApp()

	app.Name = "syndication"
	app.Usage = "A Super Simple RSS server"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "config",
			Usage: "Path to configuration file to use",
		},
		cli.StringFlag{
			Name:  "socket",
			Usage: "Path to admin socket",
		},
		cli.BoolFlag{
			Name:  "admin",
			Usage: "Enable/Disable admin",
		},
		cli.BoolFlag{
			Name:  "sync",
			Usage: "Enable/Disable sync",
		},
	}

	app.Action = startApp

	app.Run(os.Args)
}
{'fraction_non_alphanumeric': 0.12197731649903702, 'fraction_numerical': 0.0021399529210357373, 'mean_word_length': 3.405278039585297, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2378178', 'n_tokens_mistral': 1720, 'n_tokens_neox': 1570, 'n_words': 478}