- had to add a Type field to interface DbEntry so that db.List()
is able to distinguish between Upload and Form properly.
- added form describe and delete commands
- added --query parameter to form+upload list for filtering
This commit is contained in:
2023-03-30 10:22:57 +02:00
parent 26f2b25e22
commit 8a791d8017
13 changed files with 208 additions and 40 deletions

View File

@@ -18,6 +18,7 @@ package cmd
import (
//"errors"
"errors"
"github.com/spf13/cobra"
"github.com/tlinden/ephemerup/common"
"github.com/tlinden/ephemerup/upctl/cfg"
@@ -45,6 +46,8 @@ func FormCommand(conf *cfg.Config) *cobra.Command {
formCmd.AddCommand(FormCreateCommand(conf))
formCmd.AddCommand(FormListCommand(conf))
formCmd.AddCommand(FormDeleteCommand(conf))
formCmd.AddCommand(FormDescribeCommand(conf))
return formCmd
}
@@ -88,9 +91,57 @@ func FormListCommand(conf *cfg.Config) *cobra.Command {
// options
listCmd.PersistentFlags().StringVarP(&conf.Apicontext, "apicontext", "", "", "Filter by given API context")
listCmd.PersistentFlags().StringVarP(&conf.Query, "query", "q", "", "Filter by given query regexp")
listCmd.Aliases = append(listCmd.Aliases, "ls")
listCmd.Aliases = append(listCmd.Aliases, "l")
return listCmd
}
func FormDeleteCommand(conf *cfg.Config) *cobra.Command {
var deleteCmd = &cobra.Command{
Use: "delete [options] <id>",
Short: "Delete an form",
Long: `Delete an form identified by its id`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("No id specified to delete!")
}
// errors at this stage do not cause the usage to be shown
cmd.SilenceUsage = true
return lib.Delete(os.Stdout, conf, args, common.TypeForm)
},
}
deleteCmd.Aliases = append(deleteCmd.Aliases, "rm")
deleteCmd.Aliases = append(deleteCmd.Aliases, "d")
return deleteCmd
}
func FormDescribeCommand(conf *cfg.Config) *cobra.Command {
var listCmd = &cobra.Command{
Use: "describe [options] form-id",
Long: "Show detailed informations about an form object.",
Short: `Describe an form.`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("No id specified to delete!")
}
// errors at this stage do not cause the usage to be shown
cmd.SilenceUsage = true
return lib.Describe(os.Stdout, conf, args, common.TypeForm)
},
}
listCmd.Aliases = append(listCmd.Aliases, "des")
listCmd.Aliases = append(listCmd.Aliases, "info")
listCmd.Aliases = append(listCmd.Aliases, "i")
return listCmd
}