Skip to content

Commit df9af29

Browse files
authored
login: default to SRC_ENDPOINT (#414)
1 parent 0a4b26b commit df9af29

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ All notable changes to `src-cli` are documented in this file.
1515

1616
### Changed
1717

18+
- `src login` now defaults to validating against `SRC_ENDPOINT` if configured.
19+
1820
### Fixed
1921

2022
### Removed

cmd/src/login.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ Examples:
3838
if err := flagSet.Parse(args); err != nil {
3939
return err
4040
}
41-
if len(args) != 1 {
42-
return &usageError{errors.New("expected exactly one argument: the Sourcegraph URL")}
41+
endpoint := cfg.Endpoint
42+
if len(args) == 1 {
43+
endpoint = args[0]
4344
}
44-
endpointArg := args[0]
45-
return loginCmd(context.Background(), cfg, endpointArg, os.Stdout)
45+
if endpoint == "" {
46+
return &usageError{errors.New("expected exactly one argument: the Sourcegraph URL, or SRC_ENDPOINT to be set")}
47+
}
48+
49+
return loginCmd(context.Background(), cfg, endpoint, os.Stdout)
4650
}
4751

4852
commands = append(commands, &command{

0 commit comments

Comments
 (0)