add history flag
This commit is contained in:
+15
-1
@@ -14,6 +14,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"golang.nytpu.com/comitium/localizations"
|
"golang.nytpu.com/comitium/localizations"
|
||||||
@@ -68,7 +69,13 @@ func main() {
|
|||||||
// make sure it exists so we can start working with files in it
|
// make sure it exists so we can start working with files in it
|
||||||
os.MkdirAll(dataPath, os.ModePerm)
|
os.MkdirAll(dataPath, os.ModePerm)
|
||||||
|
|
||||||
err := core.Init(dataPath, localizer, 0)
|
days, err := getHist()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprint(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = core.Init(dataPath, localizer, days)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, core.TranslateStringLocalizer(
|
fmt.Fprintf(os.Stderr, core.TranslateStringLocalizer(
|
||||||
localizer, "%s\n",
|
localizer, "%s\n",
|
||||||
@@ -203,6 +210,13 @@ func getLang() *localizations.Localizer {
|
|||||||
return localizations.New(lang.String(), supportedLangs[0].String())
|
return localizations.New(lang.String(), supportedLangs[0].String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getHist() (days int, err error) {
|
||||||
|
if env := os.Getenv("COMITIUM_HISTORY"); env != "" && *histFlag != 31 {
|
||||||
|
return strconv.Atoi(env)
|
||||||
|
}
|
||||||
|
return *histFlag, nil
|
||||||
|
}
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage:\n")
|
fmt.Fprintf(os.Stderr, "Usage:\n")
|
||||||
fmt.Fprintf(os.Stderr, " %v <command> [FLAGS] [ARGUMENTS]\n\n", os.Args[0])
|
fmt.Fprintf(os.Stderr, " %v <command> [FLAGS] [ARGUMENTS]\n\n", os.Args[0])
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ var (
|
|||||||
|
|
||||||
dataFlag = globalFs.StringP("data", "d", "", "The data directory where comitium will store its files")
|
dataFlag = globalFs.StringP("data", "d", "", "The data directory where comitium will store its files")
|
||||||
langFlag = globalFs.StringP("lang", "l", "en-US", "The language that comitium will use when outputting its files")
|
langFlag = globalFs.StringP("lang", "l", "en-US", "The language that comitium will use when outputting its files")
|
||||||
|
histFlag = globalFs.IntP("history", "h", 31, "The number of days of article history to display on feed.gmi")
|
||||||
)
|
)
|
||||||
|
|
||||||
// command holds fields used for printing information about a command.
|
// command holds fields used for printing information about a command.
|
||||||
|
|||||||
Reference in New Issue
Block a user