From 634eda6428cea4f20a716e4c9b61584f783958b8 Mon Sep 17 00:00:00 2001 From: Ayhan Mesin Date: Thu, 26 Oct 2023 15:28:08 +0200 Subject: [PATCH] add initial backup cmd --- cmd/backup.go | 37 +++++++++++++++++++++++++++++++++++++ cmd/root.go | 15 ++------------- main.go | 17 ++++++++++++++--- 3 files changed, 53 insertions(+), 16 deletions(-) create mode 100644 cmd/backup.go diff --git a/cmd/backup.go b/cmd/backup.go new file mode 100644 index 0000000..07c7dbc --- /dev/null +++ b/cmd/backup.go @@ -0,0 +1,37 @@ +/* +* Copyright 2023 cluetec GmbH +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// backupCmd represents the backup command +var backupCmd = &cobra.Command{ + Use: "backup", + Short: "A brief description of your command", + 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. +This application is a tool to generate the needed files +to quickly create a Cobra application.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("backup called") + }, +} diff --git a/cmd/root.go b/cmd/root.go index 097356c..b6a0b9d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -23,7 +23,7 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "lifeboat", + Use: "lb", Short: "A brief description of your application", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your application. For example: @@ -31,9 +31,6 @@ examples and usage of using your application. 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.`, - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, } // Execute adds all child commands to the root command and sets flags appropriately. @@ -46,13 +43,5 @@ func Execute() { } func init() { - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.lifeboat.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") + rootCmd.AddCommand(backupCmd) } diff --git a/main.go b/main.go index dfd0a22..3726735 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,18 @@ /* -Copyright © 2023 NAME HERE - -*/ +* Copyright 2023 cluetec GmbH +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. + */ package main import "github.com/cluetec/lifeboat/cmd"