mirror of
https://github.com/goreleaser/nfpm.git
synced 2026-06-19 08:05:04 +00:00
chore: remove some panics
It'll only error if the flag doesn't exist, which is not that bad, so I just removed the panics for now... like the other options set the same way.
This commit is contained in:
@@ -22,7 +22,7 @@ func newInitCmd() *initCmd {
|
||||
SilenceErrors: true,
|
||||
Args: cobra.NoArgs,
|
||||
ValidArgsFunction: cobra.NoFileCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, _ []string) error {
|
||||
if err := os.WriteFile(root.config, []byte(example), 0o666); err != nil {
|
||||
return fmt.Errorf("failed to create example file: %w", err)
|
||||
}
|
||||
@@ -31,9 +31,7 @@ func newInitCmd() *initCmd {
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&root.config, "config", "f", "nfpm.yaml", "path to the to-be-created config file")
|
||||
if err := cmd.MarkFlagFilename("config", "yaml", "yml"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = cmd.MarkFlagFilename("config", "yaml", "yml")
|
||||
|
||||
root.cmd = cmd
|
||||
return root
|
||||
|
||||
@@ -34,17 +34,14 @@ func newPackageCmd() *packageCmd {
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&root.config, "config", "f", "nfpm.yaml", "config file to be used")
|
||||
if err := cmd.MarkFlagFilename("config", "yaml", "yml"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = cmd.MarkFlagFilename("config", "yaml", "yml")
|
||||
cmd.Flags().StringVarP(&root.target, "target", "t", "", "where to save the generated package (filename, folder or empty for current folder)")
|
||||
if err := cmd.MarkFlagFilename("target"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = cmd.MarkFlagFilename("target")
|
||||
cmd.Flags().StringVarP(&root.packager, "packager", "p", "", "which packager implementation to use [apk|deb|rpm|archlinux]")
|
||||
if err := cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions([]string{"apk", "deb", "rpm", "archlinux"}, cobra.ShellCompDirectiveNoFileComp)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = cmd.RegisterFlagCompletionFunc("packager", cobra.FixedCompletions(
|
||||
[]string{"apk", "deb", "rpm", "archlinux"},
|
||||
cobra.ShellCompDirectiveNoFileComp,
|
||||
))
|
||||
|
||||
root.cmd = cmd
|
||||
return root
|
||||
|
||||
@@ -48,9 +48,7 @@ func newSchemaCmd() *schemaCmd {
|
||||
}
|
||||
|
||||
cmd.Flags().StringVarP(&root.output, "output", "o", "-", "where to save the json schema")
|
||||
if err := cmd.MarkFlagFilename("output", "json"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = cmd.MarkFlagFilename("output", "json")
|
||||
|
||||
root.cmd = cmd
|
||||
return root
|
||||
|
||||
Reference in New Issue
Block a user