mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-17 12:40:57 +01:00
added modify command for upload and form
This commit is contained in:
@@ -48,6 +48,7 @@ func FormCommand(conf *cfg.Config) *cobra.Command {
|
||||
formCmd.AddCommand(FormListCommand(conf))
|
||||
formCmd.AddCommand(FormDeleteCommand(conf))
|
||||
formCmd.AddCommand(FormDescribeCommand(conf))
|
||||
formCmd.AddCommand(FormModifyCommand(conf))
|
||||
|
||||
return formCmd
|
||||
}
|
||||
@@ -66,9 +67,12 @@ func FormCreateCommand(conf *cfg.Config) *cobra.Command {
|
||||
}
|
||||
|
||||
// options
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Expire, "expire", "e", "", "Expire setting: asap or duration (accepted shortcuts: dmh)")
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Description, "description", "D", "", "Description of the form")
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Notify, "notify", "n", "", "Email address to get notified when consumer has uploaded files")
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Expire, "expire", "e", "",
|
||||
"Expire setting: asap or duration (accepted shortcuts: dmh)")
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Description, "description", "D", "",
|
||||
"Description of the form")
|
||||
formCreateCmd.PersistentFlags().StringVarP(&conf.Notify, "notify", "n", "",
|
||||
"Email address to get notified when consumer has uploaded files")
|
||||
|
||||
formCreateCmd.Aliases = append(formCreateCmd.Aliases, "add")
|
||||
formCreateCmd.Aliases = append(formCreateCmd.Aliases, "+")
|
||||
@@ -76,6 +80,37 @@ func FormCreateCommand(conf *cfg.Config) *cobra.Command {
|
||||
return formCreateCmd
|
||||
}
|
||||
|
||||
func FormModifyCommand(conf *cfg.Config) *cobra.Command {
|
||||
var formModifyCmd = &cobra.Command{
|
||||
Use: "modify [options] <id>",
|
||||
Short: "Modify a form",
|
||||
Long: `Modify an existing form.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return cmd.Help()
|
||||
}
|
||||
|
||||
// errors at this stage do not cause the usage to be shown
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
return lib.Modify(os.Stdout, conf, args, common.TypeForm)
|
||||
},
|
||||
}
|
||||
|
||||
// options
|
||||
formModifyCmd.PersistentFlags().StringVarP(&conf.Expire, "expire", "e", "",
|
||||
"Expire setting: asap or duration (accepted shortcuts: dmh)")
|
||||
formModifyCmd.PersistentFlags().StringVarP(&conf.Description, "description", "D", "",
|
||||
"Description of the form")
|
||||
formModifyCmd.PersistentFlags().StringVarP(&conf.Notify, "notify", "n", "",
|
||||
"Email address to get notified when consumer has uploaded files")
|
||||
|
||||
formModifyCmd.Aliases = append(formModifyCmd.Aliases, "mod")
|
||||
formModifyCmd.Aliases = append(formModifyCmd.Aliases, "change")
|
||||
|
||||
return formModifyCmd
|
||||
}
|
||||
|
||||
func FormListCommand(conf *cfg.Config) *cobra.Command {
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "list [options]",
|
||||
|
||||
@@ -146,3 +146,32 @@ func DownloadCommand(conf *cfg.Config) *cobra.Command {
|
||||
|
||||
return listCmd
|
||||
}
|
||||
|
||||
func ModifyCommand(conf *cfg.Config) *cobra.Command {
|
||||
var uploadModifyCmd = &cobra.Command{
|
||||
Use: "modify [options] <id>",
|
||||
Short: "Modify an upload",
|
||||
Long: `Modify an existing upload.`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) == 0 {
|
||||
return cmd.Help()
|
||||
}
|
||||
|
||||
// errors at this stage do not cause the usage to be shown
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
return lib.Modify(os.Stdout, conf, args, common.TypeUpload)
|
||||
},
|
||||
}
|
||||
|
||||
// options
|
||||
uploadModifyCmd.PersistentFlags().StringVarP(&conf.Expire, "expire", "e", "",
|
||||
"Expire setting: asap or duration (accepted shortcuts: dmh)")
|
||||
uploadModifyCmd.PersistentFlags().StringVarP(&conf.Description, "description", "D", "",
|
||||
"Description of the upload")
|
||||
|
||||
uploadModifyCmd.Aliases = append(uploadModifyCmd.Aliases, "mod")
|
||||
uploadModifyCmd.Aliases = append(uploadModifyCmd.Aliases, "change")
|
||||
|
||||
return uploadModifyCmd
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ func Execute() {
|
||||
rootCmd.AddCommand(DeleteCommand(&conf))
|
||||
rootCmd.AddCommand(DescribeCommand(&conf))
|
||||
rootCmd.AddCommand(DownloadCommand(&conf))
|
||||
rootCmd.AddCommand(ModifyCommand(&conf))
|
||||
|
||||
// forms are being handled with its own subcommand
|
||||
rootCmd.AddCommand(FormCommand(&conf))
|
||||
|
||||
err := rootCmd.Execute()
|
||||
|
||||
Reference in New Issue
Block a user