revise build cmd i2p arg handing, drop --i2p flag and follow serve pattern instead. Pass default args to NewGarlic func

This commit is contained in:
ungrentquest
2025-04-24 22:28:51 +00:00
parent 10d4baefaa
commit 5a3788ddbc
4 changed files with 4 additions and 8 deletions

View File

@ -18,8 +18,6 @@ var buildCmd = &cobra.Command{
Use: "build",
Short: "Build newsfeeds from XML",
Run: func(cmd *cobra.Command, args []string) {
// For some reason this is the only way passing booleans from cobra to viper works
viper.GetViper().Set("i2p", i2p)
f, e := os.Stat(c.NewsFile)
if e != nil {
@ -59,17 +57,17 @@ func init() {
buildCmd.Flags().String("feedbackup", "http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/news.atom.xml", "Backup newsfeed for updates to pass to news generator")
buildCmd.Flags().String("feeduid", "", "UUID to use for the RSS feed to pass to news generator. Random if omitted")
buildCmd.Flags().String("builddir", "build", "Build directory to output feeds to")
buildCmd.Flags().BoolVar(&i2p, "i2p", false, "Enable I2P support")
serveCmd.Flags().String("samaddr", onramp.SAM_ADDR, "SAMv3 gateway address. Empty string to disable")
viper.BindPFlags(buildCmd.Flags())
}
func defaultFeedURL() string {
if !c.I2P {
if c.SamAddr == "" {
return "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/news.atom.xml"
}
garlic := &onramp.Garlic{}
garlic, _ := onramp.NewGarlic("newsgo", c.SamAddr, onramp.OPT_DEFAULTS)
defer garlic.Close()
ln, err := garlic.Listen()
if err != nil {

View File

@ -11,7 +11,6 @@ import (
)
var cfgFile string
var i2p bool
var c *config.Conf = &config.Conf{}
// rootCmd represents the base command when called without any subcommands

View File

@ -68,7 +68,7 @@ func init() {
}
func serveI2P(s *server.NewsServer) error {
garlic, err := onramp.NewGarlic("newsgo", c.SamAddr, make([]string, 0))
garlic, err := onramp.NewGarlic("newsgo", c.SamAddr, onramp.OPT_DEFAULTS)
if err != nil {
return err
}

View File

@ -3,7 +3,6 @@ package config
type Conf struct {
NewsDir string
StatsFile string
I2P bool
Http string
SamAddr string
NewsFile string