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.
- Loading branch information
1 parent
b27c4ee
commit 8b01cf1
Showing
2 changed files
with
63 additions
and
24 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,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/logrusorgru/aurora" | ||
"github.com/mainawycliffe/kamanda/oauth" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// loginCICmd represents the login:ci command | ||
var loginCICmd = &cobra.Command{ | ||
Use: "login:ci", | ||
Short: "generate an access token for use in non-interactive environments", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
noLocalhostFlag, _ := cmd.Flags().GetBool("no-localhost") | ||
if !noLocalhostFlag { | ||
oauth.LoginWithLocalhost(true) | ||
os.Exit(0) | ||
} | ||
if err := oauth.LoginWithoutLocalhost(true); err != nil { | ||
fmt.Fprint(os.Stdout, aurora.Sprintf(aurora.Red("\n\n%s\n\n"), err.Error())) | ||
os.Exit(1) | ||
} | ||
os.Exit(0) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(loginCICmd) | ||
// allow users to login without localhost | ||
loginCICmd.Flags().Bool("no-localhost", false, "copy and paste a code instead of starting a local server for authentication") | ||
} |
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