Version printing from command line arguments
This commit is contained in:
parent
fdc0fc8b97
commit
b76502c034
1 changed files with 22 additions and 13 deletions
25
main.go
25
main.go
|
|
@ -36,6 +36,7 @@ var (
|
|||
FlagConfig string
|
||||
FlagCreateUser string
|
||||
FlagChangePassword string
|
||||
FlagVersion bool
|
||||
Webengine HTMLTemplate.Engine
|
||||
config Config
|
||||
Log *slog.Logger
|
||||
|
|
@ -66,6 +67,7 @@ func init() { // {{{
|
|||
flag.BoolVar(&FlagLoremIpsum, "lorem-ipsum", false, "Replace all G- nodes with lorem ipsum paragraphs")
|
||||
flag.StringVar(&FlagCreateUser, "create-user", "", "Username for creating a new user")
|
||||
flag.StringVar(&FlagChangePassword, "change-password", "", "Change the password for the given username")
|
||||
flag.BoolVar(&FlagVersion, "version", false, "Print version and exit")
|
||||
flag.Parse()
|
||||
|
||||
RxpBearerToken = regexp.MustCompile("(?i)^\\s*Bearer\\s+(.*?)\\s*$")
|
||||
|
|
@ -76,7 +78,14 @@ func initLog() { // {{{
|
|||
Log = slog.New(slog.NewJSONHandler(os.Stdout, &opts))
|
||||
} // }}}
|
||||
func main() { // {{{
|
||||
if FlagVersion {
|
||||
fmt.Println(VERSION)
|
||||
return
|
||||
}
|
||||
|
||||
initLog()
|
||||
Log.Info("application", "version", VERSION)
|
||||
|
||||
err := readConfig(FlagConfig)
|
||||
if err != nil {
|
||||
Log.Error("config", "error", err)
|
||||
|
|
@ -502,7 +511,7 @@ func actionUserSetPreferences(w http.ResponseWriter, r *http.Request) { // {{{
|
|||
})
|
||||
} // }}}
|
||||
|
||||
func actionFileCount(w http.ResponseWriter, r *http.Request) {// {{{
|
||||
func actionFileCount(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
session := getUserSession(r)
|
||||
count, err := FileCountForUser(session.UserID)
|
||||
if err != nil {
|
||||
|
|
@ -515,8 +524,8 @@ func actionFileCount(w http.ResponseWriter, r *http.Request) {// {{{
|
|||
"OK": true,
|
||||
"Count": count,
|
||||
})
|
||||
}// }}}
|
||||
func actionFileServerUUIDs(w http.ResponseWriter, r *http.Request) {// {{{
|
||||
} // }}}
|
||||
func actionFileServerUUIDs(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
session := getUserSession(r)
|
||||
offset, _ := strconv.Atoi(r.PathValue("offset"))
|
||||
uuids, more, err := FileServerUUIDsForUser(session.UserID, offset)
|
||||
|
|
@ -531,8 +540,8 @@ func actionFileServerUUIDs(w http.ResponseWriter, r *http.Request) {// {{{
|
|||
"UUIDs": uuids,
|
||||
"MoreRowsExist": more,
|
||||
})
|
||||
}// }}}
|
||||
func actionFile(w http.ResponseWriter, r *http.Request) {// {{{
|
||||
} // }}}
|
||||
func actionFile(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
uuid := r.PathValue("uuid")
|
||||
session := getUserSession(r)
|
||||
f, md, err := FileForUser(session.UserID, uuid)
|
||||
|
|
@ -543,8 +552,8 @@ func actionFile(w http.ResponseWriter, r *http.Request) {// {{{
|
|||
}
|
||||
|
||||
http.ServeContent(w, r, md.Name, md.Modified, f)
|
||||
}// }}}
|
||||
func actionFileMetadata(w http.ResponseWriter, r *http.Request) {// {{{
|
||||
} // }}}
|
||||
func actionFileMetadata(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
uuid := r.PathValue("uuid")
|
||||
session := getUserSession(r)
|
||||
md, err := FileMetadata(session.UserID, uuid)
|
||||
|
|
@ -559,7 +568,7 @@ func actionFileMetadata(w http.ResponseWriter, r *http.Request) {// {{{
|
|||
"OK": true,
|
||||
"Metadata": md,
|
||||
})
|
||||
}// }}}
|
||||
} // }}}
|
||||
|
||||
func createNewUser(username string) { // {{{
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue