Skip to content

Commit

Permalink
Merge pull request #56 from jpmcb/cleanup
Browse files Browse the repository at this point in the history
chore: cleaning up some copy and general UX flow
  • Loading branch information
jpmcb authored Oct 20, 2023
2 parents 24fb285 + a08fea4 commit e97e256
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
4 changes: 1 addition & 3 deletions cmd/insights/contributors.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ func findRepositoryByOwnerAndRepoName(ctx context.Context, apiClient *client.API
repo, response, err := apiClient.RepositoryServiceAPI.FindOneByOwnerAndRepo(ctx, owner, repoName).Execute()
if err != nil {
if response != nil && response.StatusCode == http.StatusNotFound {
message := fmt.Sprintf("repository %s is either non-existent or has not been indexed yet", repoURL)
fmt.Println("ignoring repository issue:", message)
return nil, nil
return nil, fmt.Errorf("repository %s is either non-existent, private, or has not been indexed yet", repoURL)
}
return nil, fmt.Errorf("error while calling 'RepositoryServiceAPI.FindOneByOwnerAndRepo' with owner %q and repo %q: %w", owner, repoName, err)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/insights/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ type repositoriesOptions struct {
func NewRepositoriesCommand() *cobra.Command {
opts := &repositoriesOptions{}
cmd := &cobra.Command{
Use: "repositories url... [flags]",
Short: "Gather insights about indexed git repositories",
Long: "Gather insights about indexed git repositories. This command will show info about contributors, pull requests, etc.",
Use: "repositories url... [flags]",
Aliases: []string{"repos"},
Short: "Gather insights about indexed git repositories",
Long: "Gather insights about indexed git repositories. This command will show info about contributors, pull requests, etc.",
Args: func(cmd *cobra.Command, args []string) error {
fileFlag := cmd.Flags().Lookup(constants.FlagNameFile)
if !fileFlag.Changed && len(args) == 0 {
Expand Down
24 changes: 12 additions & 12 deletions cmd/repo-query/repo-query.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func run(opts *Options) error {
return err
}

fmt.Printf("Checking if %s/%s is indexed by us...⏳\n", owner, repo)
fmt.Printf("Checking if %s/%s is indexed by us ... \n", owner, repo)
resp, err := agent.client.HTTPClient.Get(fmt.Sprintf("%s/collection?owner=%s&name=%s&branch=%s", agent.client.Endpoint, owner, repo, opts.branch))
if err != nil {
return err
Expand All @@ -112,8 +112,8 @@ func run(opts *Options) error {
switch resp.StatusCode {
case http.StatusNotFound:
// repo is not indexed
fmt.Println("Repo not found❗")
fmt.Println("Indexing repo...⏳")
fmt.Println("Repo not found ❗")
fmt.Println("Indexing repo ... ⏳")
err := agent.indexRepo(owner, repo, opts.branch)
if err != nil {
return err
Expand Down Expand Up @@ -152,7 +152,7 @@ func (rq *repoQueryAgent) startQnALoop(owner string, repo string, branch string)

go func() {
<-c
fmt.Println("\n🍕Exiting...")
fmt.Println("\n🍕 Exiting ...")
os.Exit(0)
}()

Expand All @@ -163,7 +163,7 @@ func (rq *repoQueryAgent) startQnALoop(owner string, repo string, branch string)
if scanner.Scan() {
input := scanner.Text()
if input == "exit" {
fmt.Println("🍕Exiting...")
fmt.Println("🍕 Exiting ...")
os.Exit(0)
}
err := rq.askQuestion(input, owner, repo, branch)
Expand Down Expand Up @@ -338,11 +338,11 @@ func (rq *repoQueryAgent) processIndexChunk(chunk string) error {

switch event {
case "FETCH_REPO":
fmt.Println("Fetching Repository from GitHub...")
fmt.Println("Fetching Repository from GitHub ...")
case "EMBED_REPO":
fmt.Println("Embedding Repository...")
fmt.Println("Embedding Repository ...")
case "SAVE_EMBEDDINGS":
fmt.Println("Saving the embeddings to our database...")
fmt.Println("Saving the embeddings to our database ...")
case "ERROR":
fmt.Println("There was an error while indexing this repository.")
return errors.New("error while indexing repository")
Expand Down Expand Up @@ -378,13 +378,13 @@ func (rq *repoQueryAgent) processChatChunk(chunk string) error {

switch event {
case "SEARCH_CODEBASE":
fmt.Println("Searching the codebase for your query...🔍")
fmt.Println("Searching the codebase for your query ... 🔍")
case "SEARCH_FILE":
fmt.Printf("Searching %s for your query...🔍\n", data.(map[string]interface{})["path"])
fmt.Printf("Searching %s for your query ... 🔍\n", data.(map[string]interface{})["path"])
case "SEARCH_PATH":
fmt.Printf("Looking for %s in the codebase...🔍\n", data.(map[string]interface{})["path"])
fmt.Printf("Looking for %s in the codebase ... 🔍\n", data.(map[string]interface{})["path"])
case "GENERATE_RESPONSE":
fmt.Println("Generating a response...🧠")
fmt.Println("Generating a response ... 🧠")
case "DONE":
fmt.Println()
// the server sends the data as a string, with \n, "", and \t escaped.
Expand Down
2 changes: 1 addition & 1 deletion cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewRootCommand() (*cobra.Command, error) {
cmd.PersistentFlags().StringP(constants.FlagNameEndpoint, "e", constants.EndpointProd, "The API endpoint to send requests to")
cmd.PersistentFlags().Bool(constants.FlagNameBeta, false, fmt.Sprintf("Shorthand for using the beta OpenSauced API endpoint (\"%s\"). Supersedes the '--%s' flag", constants.EndpointBeta, constants.FlagNameEndpoint))
cmd.PersistentFlags().Bool(constants.FlagNameTelemetry, false, "Disable sending telemetry data to OpenSauced")
cmd.PersistentFlags().StringP(constants.FlagNameOutput, "o", constants.OutputTable, "The formatting style for command output")
cmd.PersistentFlags().StringP(constants.FlagNameOutput, "o", constants.OutputTable, "The formatting for command output. One of: (table, yaml, csv, json)")

cmd.AddCommand(bake.NewBakeCommand())
cmd.AddCommand(repoquery.NewRepoQueryCommand())
Expand Down
4 changes: 2 additions & 2 deletions pkg/constants/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package constants
const (
HelpTemplate = `
{{with (or .Long .Short)}}{{. | trimTrailingWhitespaces}}
{{end}}{{if or .Runnable .HasSubCommands}}{{.UsageString}}{{end}}`

// UsageTemplate is identical to the default cobra usage template,
// but utilizes wrappedFlagUsages to ensure flag usages don't wrap around
UsageTemplate = `Usage:{{if .Runnable}}
UsageTemplate = `
Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if gt (len .Aliases) 0}}
Aliases:
Expand Down

0 comments on commit e97e256

Please sign in to comment.