Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

paastech
24 changes: 24 additions & 0 deletions cmd/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"fmt"

"github.com/paastech-cloud/cli/pkg/auth"
"github.com/spf13/cobra"
)

var accountCmd = &cobra.Command{
GroupID: "account",
Use: "account",
Short: "Get infos about user account",
Long: "Get infos about user account",
RunE: func(cmd *cobra.Command, args []string) error {
status, err := auth.Status()
fmt.Println(status)
return err
},
}

func init() {
rootCmd.AddCommand(accountCmd)
}
50 changes: 50 additions & 0 deletions cmd/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cmd

import (
"fmt"

"github.com/paastech-cloud/cli/pkg/auth"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
)

var (
email string
password string
)

var loginCmd = &cobra.Command{
GroupID: "account",
Use: "login",
Short: "Log in to PaaSTech.cloud",
Long: "Log in to PaaSTech.cloud",
RunE: func(cmd *cobra.Command, args []string) error {
email, _ := cmd.Flags().GetString("email")
password, _ := cmd.Flags().GetString("password")

if len(email) == 0 || len(password) == 0 {
fmt.Print("Email: ")
fmt.Scan(&email)

fmt.Print("Password: ")
p, _ := terminal.ReadPassword(0)
password = string(p)
fmt.Print("\n")
}

fmt.Printf("🔐 Logging in as %s...\n", email)
err := auth.Login(email, password)
if err == nil {
fmt.Println("✅ Login successful")
}
return err
},
}

func init() {
rootCmd.AddCommand(loginCmd)

loginCmd.Flags().StringVarP(&email, "email", "e", "", "Email")
loginCmd.Flags().StringVarP(&password, "password", "p", "", "Password")
loginCmd.MarkFlagsRequiredTogether("email", "password")
}
23 changes: 23 additions & 0 deletions cmd/logout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"fmt"

"github.com/paastech-cloud/cli/pkg/auth"
"github.com/spf13/cobra"
)

var logoutCmd = &cobra.Command{
GroupID: "account",
Use: "logout",
Short: "Log out from PaaSTech.cloud",
Long: "Log out from PaaSTech.cloud",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("🚪 Logging out")
return auth.Logout()
},
}

func init() {
rootCmd.AddCommand(logoutCmd)
}
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var rootCmd = &cobra.Command{

🔗 Find more informations at: TBA
`,
SilenceUsage: true,
}

func Execute() {
Expand All @@ -23,3 +24,7 @@ func Execute() {
os.Exit(1)
}
}

func init() {
rootCmd.AddGroup(&cobra.Group{ID: "account", Title: "Account Commands"})
}
22 changes: 7 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ module github.com/paastech-cloud/cli
go 1.20

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/spf13/cobra v1.7.0
golang.org/x/crypto v0.10.0
)

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.16.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
)
474 changes: 6 additions & 468 deletions go.sum

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package auth

func Login(email string, password string) error {
return nil
}

func Logout() error {
return nil
}

func Status() (string, error) {
return "status not implemented yet", nil
}