mirror of
https://github.com/v1k45/pastepass.git
synced 2026-01-07 05:57:08 +00:00
Add version information; update release workflow
This commit is contained in:
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -29,3 +29,4 @@ jobs:
|
||||
goarch: ${{ matrix.goarch }}
|
||||
compress_assets: false
|
||||
asset_name: pastepass-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
ldflags: -X "github.com/v1k45/pastepass/config.Version=${{ github.ref_name }}"
|
||||
|
||||
@@ -5,4 +5,5 @@ var (
|
||||
AppName = "PastePass"
|
||||
DBPath = "pastepass.boltdb"
|
||||
ResetDB = false
|
||||
Version = "0.00-dev"
|
||||
)
|
||||
|
||||
27
main.go
27
main.go
@@ -2,22 +2,19 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/v1k45/pastepass/config"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/v1k45/pastepass/config"
|
||||
"github.com/v1k45/pastepass/db"
|
||||
"github.com/v1k45/pastepass/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&config.ServerAddr, "server-addr", config.ServerAddr, "The server address to listen on")
|
||||
flag.StringVar(&config.AppName, "app-name", config.AppName, "The name of the application (e.g. ACME PastePass)")
|
||||
flag.StringVar(&config.DBPath, "db-path", config.DBPath, "The path to the database file")
|
||||
flag.BoolVar(&config.ResetDB, "reset-db", config.ResetDB, "Reset the database on startup")
|
||||
flag.Parse()
|
||||
parseFlags()
|
||||
|
||||
// Open the database
|
||||
boltdb, err := db.NewDB(config.DBPath, config.ResetDB)
|
||||
@@ -26,9 +23,23 @@ func main() {
|
||||
}
|
||||
go boltdb.DeleteExpiredPeriodically(time.Minute * 5)
|
||||
|
||||
slog.Info("starting_server", "server_addr", config.ServerAddr, "app_name", config.AppName, "db_name", config.DBPath)
|
||||
|
||||
// Start the web server
|
||||
slog.Info("starting_server", "server_addr", config.ServerAddr, "app_name", config.AppName, "db_name", config.DBPath)
|
||||
handler := web.NewHandler(boltdb)
|
||||
http.ListenAndServe(config.ServerAddr, handler.Router())
|
||||
}
|
||||
|
||||
func parseFlags() {
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("pastepass - %s\n\n", config.Version)
|
||||
fmt.Fprintf(flag.CommandLine.Output(), "Usage:\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.StringVar(&config.ServerAddr, "server-addr", config.ServerAddr, "The server address to listen on")
|
||||
flag.StringVar(&config.AppName, "app-name", config.AppName, "The name of the application (e.g. ACME PastePass)")
|
||||
flag.StringVar(&config.DBPath, "db-path", config.DBPath, "The path to the database file")
|
||||
flag.BoolVar(&config.ResetDB, "reset-db", config.ResetDB, "Reset the database on startup")
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user