glanceapp / glanceapp/glance

if A {...} else if A {...} pattern

Open Beginner friendly
#958 2 comments 2 reactions 0 assignees View on GitHub
bug report
Dominant language
Go
Stars
37.1k
Forks
1.5k
Avg merge
1h 11m
Merged PRs (30d)
1

Description

### Description

I found 'if A {...} else if A {...} pattern inside 'parseCliOptions' function in file [cli.go](https://github.com/glanceapp/glance/blob/6c5b7a3f4cc409e31739b2914bb6636d08299126/internal/glance/cli.go#L92) on line 92.

```
func parseCliOptions() (*cliOptions, error) {
var args []string

args = os.Args[1:]
if len(args) == 0 {
intent = cliIntentServe
} else if len(args) == 1 {
....
} else if len(args) == 2 {
if args[0] == "password:hash" {
intent = cliIntentPasswordHash
} else {
return nil, unknownCommandErr
}
} else if len(args) == 2 { // <=
if args[0] == "mountpoint:info" {
intent = cliIntentMountpointInfo
} else {
return nil, unknownCommandErr
}
} else {
return nil, unknownCommandErr
}
}
```
There are 2 identical conditions 'len(args) == 2'. This means that the second 'then' branch will never be executed.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in internal/glance/cli.go at parseCliOptions, especially the two consecutive len(args) == 2 branches. Review the command argument handling and run the existing CLI-related tests, if available. Done means the password:hash and mountpoint:info paths are both reachable while other argument cases retain their current behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.