mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
7e80ade24b
Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/263 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: crapStone <me@crapstone.dev> Co-committed-by: crapStone <me@crapstone.dev>
39 lines
794 B
Go
39 lines
794 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/urfave/cli/v2"
|
|
|
|
"codeberg.org/codeberg/pages/server/database"
|
|
"codeberg.org/codeberg/pages/server/version"
|
|
)
|
|
|
|
func CreatePagesApp() *cli.App {
|
|
app := cli.NewApp()
|
|
app.Name = "pages-server"
|
|
app.Version = version.Version
|
|
app.Usage = "pages server"
|
|
app.Flags = ServerFlags
|
|
app.Commands = []*cli.Command{
|
|
Certs,
|
|
}
|
|
|
|
return app
|
|
}
|
|
|
|
func OpenCertDB(ctx *cli.Context) (certDB database.CertDB, closeFn func(), err error) {
|
|
certDB, err = database.NewXormDB(ctx.String("db-type"), ctx.String("db-conn"))
|
|
if err != nil {
|
|
return nil, nil, fmt.Errorf("could not connect to database: %w", err)
|
|
}
|
|
|
|
closeFn = func() {
|
|
if err := certDB.Close(); err != nil {
|
|
log.Error().Err(err)
|
|
}
|
|
}
|
|
|
|
return certDB, closeFn, nil
|
|
}
|