Skip to content

Commit

Permalink
feat(cmd/google_drive/upload): Add slu google-drive upload cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Oct 22, 2023
1 parent 94ca5b2 commit 2ecba35
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ import (
_ "github.com/sikalabs/slu/cmd/go_code/version_bump"
_ "github.com/sikalabs/slu/cmd/golang"
_ "github.com/sikalabs/slu/cmd/golang/build_all_platforms"
_ "github.com/sikalabs/slu/cmd/google_drive"
_ "github.com/sikalabs/slu/cmd/google_drive/upload"
_ "github.com/sikalabs/slu/cmd/helm"
_ "github.com/sikalabs/slu/cmd/helm/version_bump"
_ "github.com/sikalabs/slu/cmd/host"
Expand Down
16 changes: 16 additions & 0 deletions cmd/google_drive/google_drive.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package google_drive

import (
"github.com/sikalabs/slu/cmd/root"
"github.com/spf13/cobra"
)

var Cmd = &cobra.Command{
Use: "google-drive",
Short: "Google Drive Utils",
Aliases: []string{"gdrive", "gdr"},
}

func init() {
root.RootCmd.AddCommand(Cmd)
}
51 changes: 51 additions & 0 deletions cmd/google_drive/upload/upload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package upload

import (
parent_cmd "github.com/sikalabs/slu/cmd/google_drive"
"github.com/sikalabs/slu/utils/google_drive_utils"

"github.com/spf13/cobra"
)

var FlagClientId string
var FlagClientSecret string
var FlagAccessToken string

var Cmd = &cobra.Command{
Use: "upload",
Short: "Upload file to Goole Drive",
Aliases: []string{"u"},
Args: cobra.ExactArgs(1),
Run: func(c *cobra.Command, args []string) {
google_drive_utils.Upload(
FlagClientId,
FlagClientSecret,
FlagAccessToken,
args[0],
)
},
}

func init() {
parent_cmd.Cmd.AddCommand(Cmd)
Cmd.Flags().StringVar(
&FlagClientId,
"client-id",
"",
"Google Drive Client ID",
)
Cmd.MarkFlagRequired("client-id")
Cmd.Flags().StringVar(
&FlagClientSecret,
"client-secret",
"",
"Google Drive Client Secret",
)
Cmd.MarkFlagRequired("client-secret")
Cmd.Flags().StringVar(
&FlagAccessToken,
"access-token",
"",
"Google Drive Access Token",
)
}

0 comments on commit 2ecba35

Please sign in to comment.