Skip to content

Commit

Permalink
issue-filing can now be started in the terminal
Browse files Browse the repository at this point in the history
This requires a web browser for the issues tracker to be opened.
For example:
```shell
$ cat bugReport | drive report-issue --title "Crash on pushing"
$ drive report-issue --title "Crash on pushing" --body "Similar to #5
but here always crashes only after a timeout"
```
  • Loading branch information
odeke-em committed Dec 29, 2015
1 parent cfd947b commit 50600be
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- [Drive Server](#drive-server)
- [QR Code Share](#qr-code-share)
- [Star Or Unstar](#star-or-unstar)
- [Filing Issues](#filing-issues)
- [Revoking Account Access](#revoking-account-access)
- [Uninstalling](#uninstalling)
- [Applying patches](#applying-patches)
Expand Down Expand Up @@ -1102,6 +1103,21 @@ $ drive unstar information quest/A/B/C
$ drive unstar --id 0fM9rt0Yc9RTPaDdsNzg1dXVjM0E 0fM9rt0Yc9RTPaTVGc1pzODN1NjQ 0fM9rt0Yc9RTPV1NaNFp5WlV3dlU
```
## Filing Issues
In case of any issue, you can file one by using command `issue` aka `report-issue` aka `report`.
It takes flags `--title` `--body` `--piped`.
* If `--piped` is set, it expects to read the body from standard input).
A successful issue-filing request will open up the project's issue tracker in your web browser.
```
$ drive issue --title "Can't open my file" --body "Drive trips out everytime"
$ drive report-issue --title "Can't open my file" --body "Drive trips out everytime"
$ cat bugReport.txt | drive issue --piped --title "push: dump on pushing from this directory"
```
### Revoking Account Access
To revoke OAuth Access of drive to your account, when logged in with your Google account, go to https://security.google.com/settings/security/permissions and revoke the desired permissions
Expand Down
36 changes: 36 additions & 0 deletions cmd/drive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func main() {
bindCommandWithAliases(drive.UnStarKey, drive.DescUnStar, &unstarCmd{}, []string{})
bindCommandWithAliases(drive.ClashesKey, drive.DescFixClashes, &clashesCmd{}, []string{})
bindCommandWithAliases(drive.IdKey, drive.DescId, &idCmd{}, []string{})
bindCommandWithAliases(drive.ReportIssueKey, drive.DescReportIssue, &issueCmd{}, []string{})

command.DefineHelp(&helpCmd{})
command.ParseAndRun()
Expand Down Expand Up @@ -1611,6 +1612,41 @@ func (ccmd *clashesCmd) Run(args []string, definedFlags map[string]*flag.Flag) {
exitWithError(fn(*cmd.ById))
}

type issueCmd struct {
Piped *bool
Title *string
Body *string
}

func (ic *issueCmd) Flags(fs *flag.FlagSet) *flag.FlagSet {
ic.Piped = fs.Bool(drive.CLIOptionPiped, false, drive.DescPiped)
ic.Title = fs.String(drive.IssueTitleKey, "", drive.DescIssueTitle)
ic.Body = fs.String(drive.IssueBodyKey, "", drive.DescIssueBody)

return fs
}

func (cmd *issueCmd) Run(args []string, definedFlags map[string]*flag.Flag) {
sources, context, path := preprocessArgs(args)

meta := map[string][]string{
drive.IssueTitleKey: []string{*cmd.Title},
drive.IssueBodyKey: []string{*cmd.Body},
}

if *cmd.Piped {
meta[drive.PipedKey] = []string{fmt.Sprintf("%v", *cmd.Piped)}
}

opts := &drive.Options{
Path: path,
Sources: sources,
Meta: &meta,
}

exitWithError(drive.New(context, opts).FileIssue())
}

func initContext(args []string) *config.Context {
var err error
var gdPath string
Expand Down
7 changes: 7 additions & 0 deletions src/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ const (
PageSizeKey = "pagesize"
DriveRepoRelPath = "github.com/odeke-em/drive"
UrlKey = "url"
ReportIssueKey = "report-issue"
IssueTitleKey = "title"
IssueBodyKey = "body"
)

const (
Expand Down Expand Up @@ -180,6 +183,9 @@ const (
DescUnifiedDiff = "unified diff"
DescDiffBaseLocal = "when set uses local as the base other remote will be used as the base"
DescClashesOpById = "operate on clashes by id instead of by path"
DescIssueBody = "the detailed description of the issue being filed"
DescIssueTitle = "the title of the issue being filed"
DescReportIssue = "report an issue to the project's issue tracker"
DescId = "retrieve the fileId for the specified paths"
)

Expand Down Expand Up @@ -353,6 +359,7 @@ func createAndRegisterAliases() map[string][]string {
DeleteKey: []string{"del"},
EditDescriptionKey: []string{EditDescriptionShortKey},
IdKey: []string{"file-id"},
ReportIssueKey: []string{"issue", "report"},
}

for originalKey, aliasList := range aliases {
Expand Down

0 comments on commit 50600be

Please sign in to comment.