cmd

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunCommand = &cobra.Command{
	Use:   "run",
	Short: "Run the application",
	Long:  "Run the application",
	Args:  cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		configuration, err := config.Initialize()
		if err != nil {
			logger.Fatalf("cmd:run", "failed to initialize configuration: %s", err.Error())
		}

		db := database.NewDatabase(
			storage.NewStorage(configuration.GetDatabase().GetPath(), 0755),
			configuration.GetDatabase().GetName(),
		)

		if err := db.Start(); err != nil {
			logger.Fatalf("cmd:run", "failed to start database: %s", err.Error())
		}
		defer db.Stop()

		server.NewServer(
			configuration,
			db,
		).Run()
	},
}
View Source
var VersionCommand = &cobra.Command{
	Use:   "version",
	Short: "Display application version",
	Long:  "Get version of installed application binary",
	Run: func(cmd *cobra.Command, args []string) {
		tpl, err := template.New("").Parse(versionTemplate)
		if err != nil {
			logger.Panicf("application:version", "failed to parse version template - %s", err.Error())
		}
		v := struct {
			Version   string
			Commit    string
			GoVersion string
			BuildDate string
			BuiltBy   string
			Os        string
			Arch      string
		}{
			Version:   version.GetVersion(),
			Commit:    version.GetCommit(),
			GoVersion: runtime.Version(),
			BuildDate: version.GetBuildDate(),
			BuiltBy:   version.GetBuiltBy(),
			Os:        runtime.GOOS,
			Arch:      runtime.GOARCH,
		}
		err = tpl.Execute(os.Stdout, v)
		if err != nil {
			logger.Fatalf("application:version", "failed to generate version output - %s", err.Error())
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL