diff --git a/cmd/addUser.go b/cmd/addUser.go new file mode 100644 index 0000000..effec6e --- /dev/null +++ b/cmd/addUser.go @@ -0,0 +1,45 @@ +/* +Copyright © 2019 NAME HERE + +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" +) + +// addUserCmd represents the addUser command +var addUserCmd = &cobra.Command{ + Use: "addUser", + Short: "Add a new Firebase user", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("addUser called") + }, +} + +func init() { + authCmd.AddCommand(addUserCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // addUserCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // addUserCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/addUsers.go b/cmd/addUsers.go new file mode 100644 index 0000000..695b66c --- /dev/null +++ b/cmd/addUsers.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +// addUsersCmd represents the addUsers command +var addUsersCmd = &cobra.Command{ + Use: "addUsers", + Short: "Add new multiple Firebase Users", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("addUsers called") + }, +} + +func init() { + authCmd.AddCommand(addUsersCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // addUsersCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // addUsersCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/auth.go b/cmd/auth.go new file mode 100644 index 0000000..f967f93 --- /dev/null +++ b/cmd/auth.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// authCmd represents the auth command +var authCmd = &cobra.Command{ + Use: "auth", + Short: "Perform Firebase Auth Operations", + Long: `Perform Firebase Auth Operations`, + // Run: func(cmd *cobra.Command, args []string) { + // fmt.Println("auth called") + // }, +} + +func init() { + rootCmd.AddCommand(authCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // authCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // authCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git a/cmd/deleteUser.go b/cmd/deleteUser.go new file mode 100644 index 0000000..a6c6266 --- /dev/null +++ b/cmd/deleteUser.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "fmt" + "log" + "context" + + "github.com/mainawycliffe/firebase-cli/auth" + "github.com/spf13/cobra" +) + +// deleteUserCmd represents the deleteUser command +var deleteUserCmd = &cobra.Command{ + Use: "deleteUser", + Short: "Delete a Firebase User", + Run: func(cmd *cobra.Command, args []string) { + + uid, err := cmd.Flags().GetString("uid") + + if err != nil { + log.Fatalf("Error while reading uid flag: %s", err.Error()) + } + + fmt.Println(fmt.Sprintf("deleteUser called %v", uid)) + + // call firebase auth to delete firebase + err = auth.DeleteFirebaseUser(context.Background(), nil, uid) + + if err != nil { + log.Fatalf("%s", err.Error()) + } + }, +} + +func init() { + authCmd.AddCommand(deleteUserCmd) + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + deleteUserCmd.Flags().String("uid", "", "The UID of the Firebase User you want to delete (required)") + _ = deleteUserCmd.MarkFlagRequired("uid") +} diff --git a/cmd/root.go b/cmd/root.go index 7a50e1e..3f0a4fe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,9 +22,6 @@ var rootCmd = &cobra.Command{ It provided addition functionality currently not available to via the Official Firebase Tool such as Managing Users, Databases etc from the CLI. `, - // 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.