Skip to content

Commit c64b62d

Browse files
authored
Run completion script generation without previous setup (#386)
* Run completion script generation without previous setup * Handle like help or init
1 parent 70fcf24 commit c64b62d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Sources/Swiftly/Proxy.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ public enum Proxy {
3232

3333
if CommandLine.arguments.count == 1 {
3434
// User ran swiftly with no extra arguments in an uninstalled environment, so we jump directly into
35-
// an simple init.
35+
// a simple init.
3636
try await Init.execute(ctx, assumeYes: false, noModifyProfile: false, overwrite: false, platform: nil, verbose: false, skipInstall: false, quietShellFollowup: false)
3737
return
38-
} else if CommandLine.arguments.count >= 2 && CommandLine.arguments[1] == "init" {
39-
// 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.
4040
await Swiftly.main()
4141
return
42-
} else if CommandLine.arguments.count == 2 && (CommandLine.arguments[1] == "--help" || CommandLine.arguments[1] == "--experimental-dump-help") {
43-
// 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.
4444
await Swiftly.main()
4545
return
4646
} else {
47-
// We've been invoked outside the "init" subcommand and we're not yet configured.
4847
// This will throw if the configuration couldn't be loaded and give the user an actionable message.
4948
throw err
5049
}

0 commit comments

Comments
 (0)