Added title, link and description to cli args.

This commit is contained in:
Jason Streifling 2024-04-07 19:29:35 +02:00
parent d9bf79d5f8
commit b5f0fe8985
3 changed files with 56 additions and 45 deletions

View File

@ -3,42 +3,52 @@ testdata_dir = "testdata"
tmp_dir = "tmp" tmp_dir = "tmp"
[build] [build]
args_bin = [] args_bin = [
bin = "./tmp/main -domain localhost:8080 -key tmp/key.gob -log tmp/cpolis.log -pics tmp/pics -rss tmp/orientexpress_alle.rss -web web" "-desc 'Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität'",
cmd = "go build -o ./tmp/main ./cmd/main.go" "-domain localhost:8080",
delay = 0 "-key tmp/key.gob",
exclude_dir = ["assets", "tmp", "vendor", "testdata"] "-link https://distrikt-ni-st.de",
exclude_file = [] "-log tmp/cpolis.log",
exclude_regex = ["_test.go"] "-pics tmp/pics",
exclude_unchanged = false "-rss tmp/orientexpress_alle.rss",
follow_symlink = false "-title 'Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt'",
full_bin = "" "-web web"
include_dir = [] ]
include_ext = ["go", "tpl", "tmpl", "html", "css"] bin = "./tmp/main"
include_file = [] cmd = "go build -o ./tmp/main ./cmd/main.go"
kill_delay = "0s" delay = 0
log = "build-errors.log" exclude_dir = ["assets", "tmp", "vendor", "testdata"]
poll = false exclude_file = []
poll_interval = 0 exclude_regex = ["_test.go"]
rerun = false exclude_unchanged = false
rerun_delay = 500 follow_symlink = false
send_interrupt = false full_bin = ""
stop_on_error = false include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "css"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color] [color]
app = "" app = ""
build = "yellow" build = "yellow"
main = "magenta" main = "magenta"
runner = "green" runner = "green"
watcher = "cyan" watcher = "cyan"
[log] [log]
main_only = false main_only = false
time = false time = false
[misc] [misc]
clean_on_exit = false clean_on_exit = false
[screen] [screen]
clear_on_rebuild = false clear_on_rebuild = false
keep_scroll = true keep_scroll = true

View File

@ -7,14 +7,17 @@ import (
) )
type CliArgs struct { type CliArgs struct {
DBName string Description string
Domain string DBName string
KeyFile string Domain string
LogFile string KeyFile string
Port string Link string
PicsDir string LogFile string
RSSFile string Port string
WebDir string PicsDir string
RSSFile string
Title string
WebDir string
} }
func HandleCliArgs() (*CliArgs, error) { func HandleCliArgs() (*CliArgs, error) {
@ -22,12 +25,15 @@ func HandleCliArgs() (*CliArgs, error) {
cliArgs := new(CliArgs) cliArgs := new(CliArgs)
flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name") flag.StringVar(&cliArgs.DBName, "db", "cpolis", "DB name")
flag.StringVar(&cliArgs.Description, "desc", "Description", "Channel description")
flag.StringVar(&cliArgs.Domain, "domain", "", "domain name") flag.StringVar(&cliArgs.Domain, "domain", "", "domain name")
keyFile := flag.String("key", "/var/www/cpolis/cpolis.key", "key file") keyFile := flag.String("key", "/var/www/cpolis/cpolis.key", "key file")
flag.StringVar(&cliArgs.Link, "link", "Link", "Channel Link")
logFile := flag.String("log", "/var/log/cpolis.log", "log file") logFile := flag.String("log", "/var/log/cpolis.log", "log file")
flag.StringVar(&cliArgs.PicsDir, "pics", "pics", "pictures directory") flag.StringVar(&cliArgs.PicsDir, "pics", "pics", "pictures directory")
port := flag.Int("port", 8080, "port") port := flag.Int("port", 8080, "port")
rssFile := flag.String("rss", "/var/www/cpolis/cpolis.rss", "RSS file") rssFile := flag.String("rss", "/var/www/cpolis/cpolis.rss", "RSS file")
flag.StringVar(&cliArgs.Title, "title", "Title", "Channel title")
webDir := flag.String("web", "/var/www/cpolis/web", "web directory") webDir := flag.String("web", "/var/www/cpolis/web", "web directory")
flag.Parse() flag.Parse()

View File

@ -338,12 +338,7 @@ func PublishArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) ht
return return
} }
feed, err := control.GenerateRSS( feed, err := control.GenerateRSS(db, c.ChanTitle, c.ChanLink, c.ChanDescription)
db,
"Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt",
"https://distrikt-ni-st.de",
"Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität",
)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)