This repository has been archived by the owner on May 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scafold some commands for firebase auth
- Loading branch information
1 parent
ccf81dc
commit 6510a78
Showing
5 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright © 2019 NAME HERE <EMAIL ADDRESS> | ||
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters