-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a command to open a stack in your browser (#117)
- Loading branch information
Showing
9 changed files
with
401 additions
and
82 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 structs | ||
|
||
import "github.com/shurcooL/graphql" | ||
|
||
// SearchInput is the main object provided to any search query. | ||
type SearchInput struct { | ||
First *graphql.Int `json:"first"` | ||
After *graphql.String `json:"after"` | ||
FullTextSearch *graphql.String `json:"fullTextSearch"` | ||
Predicates *[]QueryPredicate `json:"predicates"` | ||
} | ||
|
||
// QueryPredicate Field and Constraint pair | ||
// for search input. | ||
type QueryPredicate struct { | ||
Field graphql.String `json:"field"` | ||
Constraint QueryFieldConstraint `json:"constraint"` | ||
} | ||
|
||
// QueryFieldConstraint is a constraint used | ||
// in a search query. | ||
type QueryFieldConstraint struct { | ||
BooleanEquals *[]graphql.Boolean `json:"booleanEquals"` | ||
EnumEquals *[]graphql.String `json:"enumEquals"` | ||
StringMatches *[]graphql.String `json:"stringMatches"` | ||
} | ||
|
||
// PageInfo is the extra information about | ||
// a searched page. | ||
type PageInfo struct { | ||
EndCursor string `json:"endCursor"` | ||
HasNextPage bool `json:"hasNextPage"` | ||
HasPreviousPage bool `json:"hasPreviousPage"` | ||
} |
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
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
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,38 @@ | ||
package internal | ||
|
||
import ( | ||
"os/exec" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// OpenWebBrowser will try to open the default browser | ||
// on a the callers machine. It supports windows, darwin and windows. | ||
func OpenWebBrowser(url string) error { | ||
var cmd *exec.Cmd | ||
switch runtime.GOOS { | ||
case "linux": | ||
cmd = exec.Command("xdg-open", url) | ||
case "darwin": | ||
cmd = exec.Command("open", url) | ||
case "windows": | ||
r := strings.NewReplacer("&", "^&") | ||
cmd = exec.Command("cmd", "/c", "start", r.Replace(url)) //#nosec | ||
default: | ||
return errors.New("unsupported platform") | ||
} | ||
|
||
err := cmd.Start() | ||
if err != nil { | ||
return errors.Wrap(err, "could not open the browser") | ||
} | ||
|
||
err = cmd.Wait() | ||
if err != nil { | ||
return errors.Wrap(err, "could not wait for the opening browser") | ||
} | ||
|
||
return nil | ||
} |
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
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
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
Oops, something went wrong.