Skip to content

Commit d446845

Browse files
authored
Handle like help or init
1 parent 510a6a7 commit d446845

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Sources/Swiftly/Proxy.swift

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ public enum Proxy {
1414
}
1515

1616
guard binName != "swiftly" else {
17-
if CommandLine.arguments.count > 1, CommandLine.arguments[1] == "--generate-completion-script" {
18-
// If the first argument is for completion script generation, we let swiftly handle it and finish.
19-
return await Swiftly.main()
20-
}
2117
// Treat this as a swiftly invocation, but first check that we are installed, bootstrapping
2218
// the installation process if we aren't.
2319
let configResult: Result<Config, any Error>
@@ -36,19 +32,18 @@ public enum Proxy {
3632

3733
if CommandLine.arguments.count == 1 {
3834
// User ran swiftly with no extra arguments in an uninstalled environment, so we jump directly into
39-
// an simple init.
35+
// a simple init.
4036
try await Init.execute(ctx, assumeYes: false, noModifyProfile: false, overwrite: false, platform: nil, verbose: false, skipInstall: false, quietShellFollowup: false)
4137
return
42-
} else if CommandLine.arguments.count >= 2 && CommandLine.arguments[1] == "init" {
43-
// Let the user run the init command with their arguments, if any.
38+
} else if CommandLine.arguments.count >= 2 && ["init", "--generate-completion-script"].contains(CommandLine.arguments[1]) {
39+
// Let the user run the init command or completion script generation with arguments, if any.
4440
await Swiftly.main()
4541
return
46-
} else if CommandLine.arguments.count == 2 && (CommandLine.arguments[1] == "--help" || CommandLine.arguments[1] == "--experimental-dump-help") {
47-
// Allow the showing of help information
42+
} else if CommandLine.arguments.count == 2 && ["--help", "--experimental-dump-help"].contains(CommandLine.arguments[1]) {
43+
// Just print help information.
4844
await Swiftly.main()
4945
return
5046
} else {
51-
// We've been invoked outside the "init" subcommand and we're not yet configured.
5247
// This will throw if the configuration couldn't be loaded and give the user an actionable message.
5348
throw err
5449
}

0 commit comments

Comments
 (0)