mirror of
https://github.com/goreleaser/nfpm.git
synced 2026-06-19 08:05:04 +00:00
5c895f6e80
* feat: jsonschema Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * fix: gitattr Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * docs: schema Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * docs: schema Signed-off-by: Carlos A Becker <caarlos0@gmail.com> * docs: improvements Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
_ "github.com/goreleaser/nfpm/v2/apk"
|
|
_ "github.com/goreleaser/nfpm/v2/deb"
|
|
_ "github.com/goreleaser/nfpm/v2/rpm"
|
|
)
|
|
|
|
func Execute(version string, exit func(int), args []string) {
|
|
newRootCmd(version, exit).Execute(args)
|
|
}
|
|
|
|
type rootCmd struct {
|
|
cmd *cobra.Command
|
|
exit func(int)
|
|
}
|
|
|
|
func (cmd *rootCmd) Execute(args []string) {
|
|
cmd.cmd.SetArgs(args)
|
|
|
|
if err := cmd.cmd.Execute(); err != nil {
|
|
fmt.Println(err.Error())
|
|
cmd.exit(1)
|
|
}
|
|
}
|
|
|
|
func newRootCmd(version string, exit func(int)) *rootCmd {
|
|
root := &rootCmd{
|
|
exit: exit,
|
|
}
|
|
cmd := &cobra.Command{
|
|
Use: "nfpm",
|
|
Short: "packages apps on RPM, Deb and APK formats based on a YAML configuration file",
|
|
Long: `nFPM is a simple, 0-dependencies, deb, rpm and apk packager.`,
|
|
Version: version,
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
Args: cobra.NoArgs,
|
|
}
|
|
|
|
cmd.AddCommand(
|
|
newInitCmd().cmd,
|
|
newPackageCmd().cmd,
|
|
newDocsCmd().cmd,
|
|
newSchemaCmd().cmd,
|
|
)
|
|
|
|
root.cmd = cmd
|
|
return root
|
|
}
|