reworked backupsession

This commit is contained in:
jandre 2021-02-16 22:17:02 +01:00
parent 022180febb
commit 680c23460b

View File

@ -16,41 +16,52 @@ limitations under the License.
package cmd package cmd
import ( import (
"github.com/desmo999r/formolcli/pkg/backupsession" "github.com/desmo999r/formolcli/pkg/server"
"github.com/desmo999r/formolcli/pkg/session"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// backupsessionCmd represents the backupsession command var serverBackupSessionCmd = &cobra.Command{
var createBackupsessionCmd = &cobra.Command{ Use: "server",
Use: "backupsession",
Short: "A brief description of your command", Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example: and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
server.Server()
},
}
var createBackupSessionCmd = &cobra.Command{
Use: "create",
Short: "Creates a backupsession",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications. Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files This application is a tool to generate the needed files
to quickly create a Cobra application.`, to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
name, _ := cmd.Flags().GetString("name") name, _ := cmd.Flags().GetString("name")
namespace, _ := cmd.Flags().GetString("namespace") namespace, _ := cmd.Flags().GetString("namespace")
backupsession.CreateBackupSession(name, namespace) session.CreateBackupSession(name, namespace)
}, },
} }
func init() { var backupSessionCmd = &cobra.Command{
createCmd.AddCommand(createBackupsessionCmd) Use: "backupsession",
Short: "backupsession related commands",
// Here you will define your flags and configuration settings. }
// Cobra supports Persistent Flags which will work for this command func init() {
// and all subcommands, e.g.: rootCmd.AddCommand(backupSessionCmd)
// backupsessionCmd.PersistentFlags().String("foo", "", "A help for foo") backupSessionCmd.AddCommand(createBackupSessionCmd)
backupSessionCmd.AddCommand(serverBackupSessionCmd)
// Cobra supports local flags which will only run when this command createBackupSessionCmd.Flags().String("namespace", "", "The referenced BackupSessionConfiguration namespace")
// is called directly, e.g.: createBackupSessionCmd.Flags().String("name", "", "The referenced BackupSessionConfiguration name")
// backupsessionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") createBackupSessionCmd.MarkFlagRequired("namespace")
createBackupsessionCmd.Flags().String("namespace", "", "The referenced BackupSessionConfiguration namespace") createBackupSessionCmd.MarkFlagRequired("name")
createBackupsessionCmd.Flags().String("name", "", "The referenced BackupSessionConfiguration name")
createBackupsessionCmd.MarkFlagRequired("namespace")
createBackupsessionCmd.MarkFlagRequired("name")
} }