Skip to content

Commit

Permalink
Merge pull request #107 from hirosassa/add-google-drive
Browse files Browse the repository at this point in the history
add google workspace commands
  • Loading branch information
KeisukeYamashita committed Jun 27, 2021
2 parents a5dac88 + e42cd96 commit c20cffd
Show file tree
Hide file tree
Showing 6 changed files with 377 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
[google]
[google.alias]

[googleworkspace]
[googleworkspace.alias]

[youtube]
[youtube.alias]

Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- [GCP](#gcp)
- [Github](#github)
- [Google](#google)
- [GoogleWorkspace](#googleworkspace)
- [Pagerduty](#pagerduty)
- [Youtube](#youtube)
- [(Advanced): Docker image](#advanced-docker-image)
Expand Down Expand Up @@ -382,6 +383,29 @@ $ biko g s -q "How to configure biko"

Blazing fast.

### Google Workspace

* Open Google Workspace search from your terminal.

```
$ biko googleworkspace [product] [flag(s)]
# or
$ biko gw [product] [flag(s)]
```

| Product | What | Command | Flags(Optional) |
| :----: | :----: | :----: | :----: |
| drive | Search on Google Drive | `drive`, `dr` | `--query, -q` |
| document | Search on Google Docs | `document`, `doc` | `--query, -q` |
| document | Create a new Google Docs | `document`, `doc` | `--new, -n` |
| spreadsheets | Search on Google Sheets | `spreadsheets`, `ss` | `--query, -q` |
| spreadsheets | Create a new Google Sheets | `spreadsheets`, `ss` | `--new, -n` |
| presentation | Search on Google Slides | `presentation`, `pr` | `--query, -q` |
| presentation | Create a new Google Slides | `presentation`, `pr` | `--new, -n` |
| forms | Search on Google Forms | `forms`, `fm` | `--query, -q` |
| forms | Create a new Google Forms | `forms`, `fm` | `--new, -n` |


### Pagerduty

* If you are using SSO, you need to pass `--org` or configure `BIKO_PAGERDUTY`
Expand Down
23 changes: 12 additions & 11 deletions alias/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ var (

// TomlConfig ...
type TomlConfig struct {
AWS map[string]interface{} `toml:"aws"`
Azure map[string]interface{} `toml:"azure"`
GCP map[string]interface{} `toml:"gcp"`
Datadog map[string]interface{} `toml:"datadog"`
Google map[string]interface{} `toml:"google"`
Youtube map[string]interface{} `toml:"youtube"`
PagerDuty map[string]interface{} `toml:"pagerduty"`
Github map[string]interface{} `toml:"github"`
CircleCI map[string]interface{} `toml:"circleci"`
Firebase map[string]interface{} `toml:"firebase"`
JIRA map[string]interface{} `toml:"jira"`
AWS map[string]interface{} `toml:"aws"`
Azure map[string]interface{} `toml:"azure"`
GCP map[string]interface{} `toml:"gcp"`
Datadog map[string]interface{} `toml:"datadog"`
Google map[string]interface{} `toml:"google"`
GoogleWorkspace map[string]interface{} `toml:"googleworkspace"`
Youtube map[string]interface{} `toml:"youtube"`
PagerDuty map[string]interface{} `toml:"pagerduty"`
Github map[string]interface{} `toml:"github"`
CircleCI map[string]interface{} `toml:"circleci"`
Firebase map[string]interface{} `toml:"firebase"`
JIRA map[string]interface{} `toml:"jira"`
}

// GetConfig ...
Expand Down
171 changes: 171 additions & 0 deletions cli/googleworkspace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// Copyright 2019 The Biko Authors.
//
// 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 cli

import (
"github.com/KeisukeYamashita/biko/browser"
"github.com/KeisukeYamashita/biko/providers/googleworkspace"
"github.com/urfave/cli"
)

func newGoogleWorkspaceCmd() cli.Command {
return cli.Command{
Name: "googleworkspace",
Aliases: []string{"gw"},
Usage: "Open Google Workspace resource",
Category: categoryWebService,
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
Subcommands: []cli.Command{
newDriveCmd(),
newDocumentCmd(),
newSpreadsheetsCmd(),
newPresentationCmd(),
newFormsCmd(),
},
}
}

func newDriveCmd() cli.Command {
return cli.Command{
Name: "drive",
Aliases: []string{"dr"},
Usage: "Open Google Drive directory",
Flags: []cli.Flag{
cli.StringFlag{
Name: "query, q",
Usage: "Query to search",
},
},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
}

}

func newDocumentCmd() cli.Command {
return cli.Command{
Name: "document",
Aliases: []string{"doc"},
Usage: "Open Google Document page",
Flags: []cli.Flag{
cli.StringFlag{
Name: "query, q",
Usage: "Query a page",
},
cli.BoolFlag{
Name: "new, n",
Usage: "Create a new document (this flag prioritize over query flag)",
},
},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
}

}

func newSpreadsheetsCmd() cli.Command {
return cli.Command{
Name: "spreadsheets",
Aliases: []string{"ss"},
Usage: "Open Google Spreadsheets page",
Flags: []cli.Flag{
cli.StringFlag{
Name: "query, q",
Usage: "Query a page",
},
cli.BoolFlag{
Name: "new, n",
Usage: "Create a new spreadsheet (this flag prioritize over query flag)",
},
},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
}

}

func newPresentationCmd() cli.Command {
return cli.Command{
Name: "presentation",
Aliases: []string{"pr"},
Usage: "Open Google Slides page",
Flags: []cli.Flag{
cli.StringFlag{
Name: "query, q",
Usage: "Query a page",
},
cli.BoolFlag{
Name: "new, n",
Usage: "Create a new presentation (this flag prioritize over query flag)",
},
},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
}

}

func newFormsCmd() cli.Command {
return cli.Command{
Name: "forms",
Aliases: []string{"fm"},
Usage: "Open Google Forms page",
Flags: []cli.Flag{
cli.StringFlag{
Name: "query, q",
Usage: "Query a page",
},
cli.BoolFlag{
Name: "new, n",
Usage: "Create a new form (this flag prioritize over query flag)",
},
},
Action: func(c *cli.Context) error {
g, err := googleworkspace.GetProvider()
if err != nil {
return err
}
return browser.Open(c, g)
},
}

}
1 change: 1 addition & 0 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func rootSubCommands() []cli.Command {
newGCPCmd(),
newGithubCmd(),
newGoogleCmd(),
newGoogleWorkspaceCmd(),
newJIRACmd(),
newPagerDutyCmd(),
newVersionCmd(),
Expand Down
Loading

0 comments on commit c20cffd

Please sign in to comment.