Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ All notable changes to `src-cli` are documented in this file.

### Fixed

- `src campaign [validate|apply|preview]` now print an error and usage information if a user accidentally provides an additional argument. [#384](https://github.com/sourcegraph/src-cli/pull/384)
- Fix a regression that was introduced by [#361](https://github.com/sourcegraph/src-cli/pull/361) and caused the "Resolving repositories" step of `src campaign [apply|preview]` to crash when the search query in the campaign spec yielded file matches and repository matches from the same repository.

### Removed
Expand Down
5 changes: 5 additions & 0 deletions cmd/src/campaigns_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"flag"
"fmt"

Expand Down Expand Up @@ -57,6 +58,10 @@ Examples:
return err
}

if len(flagSet.Args()) != 0 {
return &usageError{errors.New("additional arguments not allowed")}
}

out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})

ctx, cancel := contextCancelOnInterrupt(context.Background())
Expand Down
5 changes: 5 additions & 0 deletions cmd/src/campaigns_preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"flag"
"fmt"

Expand Down Expand Up @@ -32,6 +33,10 @@ Examples:
return err
}

if len(flagSet.Args()) != 0 {
return &usageError{errors.New("additional arguments not allowed")}
}

out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})

ctx, cancel := contextCancelOnInterrupt(context.Background())
Expand Down
5 changes: 5 additions & 0 deletions cmd/src/campaigns_validate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"flag"
"fmt"

Expand Down Expand Up @@ -30,6 +31,10 @@ Examples:
return err
}

if len(flagSet.Args()) != 0 {
return &usageError{errors.New("additional arguments not allowed")}
}

specFile, err := campaignsOpenFileFlag(fileFlag)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/src/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c commander) run(flagSet *flag.FlagSet, cmdName, usageText string, args []
// Execute the subcommand.
if err := cmd.handler(flagSet.Args()[1:]); err != nil {
if _, ok := err.(*usageError); ok {
log.Println(err)
log.Printf("error: %s\n\n", err)
cmd.flagSet.Usage()
os.Exit(2)
}
Expand Down