summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-06-12 11:20:22 -0400
committerdemo <demo@antix1>2026-06-12 11:20:22 -0400
commit89ea120d7a8e001653160dffcb35f19fef6c7bfe (patch)
tree705feb6af23bf37d913c1ede672d2b9a94c1cf9a
parent317d4ba474733482492dc44385f4321456fde3e8 (diff)
refactor: remove else-branch when deciding which flag to use
-rw-r--r--main.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/main.go b/main.go
index 512f75f..5c9534f 100644
--- a/main.go
+++ b/main.go
@@ -74,16 +74,20 @@ func main() {
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
- var rawURL string
- var err error
+ rawURL := cmd.String("url")
+
+ // If rawURL is empty, it
+ // means that we supplied
+ // --shortcode instead, so use
+ // that.
+ if rawURL == "" {
+ var err error
+ shortcode := cmd.String("shortcode")
- if shortcode := cmd.String("shortcode"); shortcode != "" {
rawURL, err = getURLFromShortcode(shortcodeFilename, shortcode)
if err != nil {
return err
}
- } else {
- rawURL = cmd.String("url")
}
u, err := convertToURL(rawURL)