From 510a6a702ed069289e861d1e7b60486980d708ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Tue, 17 Jun 2025 00:11:08 +0200 Subject: [PATCH 1/2] Run completion script generation without previous setup --- Sources/Swiftly/Proxy.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Swiftly/Proxy.swift b/Sources/Swiftly/Proxy.swift index fddb6e3b..9727d662 100644 --- a/Sources/Swiftly/Proxy.swift +++ b/Sources/Swiftly/Proxy.swift @@ -14,6 +14,10 @@ public enum Proxy { } guard binName != "swiftly" else { + if CommandLine.arguments.count > 1, CommandLine.arguments[1] == "--generate-completion-script" { + // If the first argument is for completion script generation, we let swiftly handle it and finish. + return await Swiftly.main() + } // Treat this as a swiftly invocation, but first check that we are installed, bootstrapping // the installation process if we aren't. let configResult: Result From d446845bb3fadf40034cfbd397a1bf3c1e407b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Tue, 17 Jun 2025 17:06:26 +0200 Subject: [PATCH 2/2] Handle like help or init --- Sources/Swiftly/Proxy.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Sources/Swiftly/Proxy.swift b/Sources/Swiftly/Proxy.swift index 9727d662..f79be4e8 100644 --- a/Sources/Swiftly/Proxy.swift +++ b/Sources/Swiftly/Proxy.swift @@ -14,10 +14,6 @@ public enum Proxy { } guard binName != "swiftly" else { - if CommandLine.arguments.count > 1, CommandLine.arguments[1] == "--generate-completion-script" { - // If the first argument is for completion script generation, we let swiftly handle it and finish. - return await Swiftly.main() - } // Treat this as a swiftly invocation, but first check that we are installed, bootstrapping // the installation process if we aren't. let configResult: Result @@ -36,19 +32,18 @@ public enum Proxy { if CommandLine.arguments.count == 1 { // User ran swiftly with no extra arguments in an uninstalled environment, so we jump directly into - // an simple init. + // a simple init. try await Init.execute(ctx, assumeYes: false, noModifyProfile: false, overwrite: false, platform: nil, verbose: false, skipInstall: false, quietShellFollowup: false) return - } else if CommandLine.arguments.count >= 2 && CommandLine.arguments[1] == "init" { - // Let the user run the init command with their arguments, if any. + } else if CommandLine.arguments.count >= 2 && ["init", "--generate-completion-script"].contains(CommandLine.arguments[1]) { + // Let the user run the init command or completion script generation with arguments, if any. await Swiftly.main() return - } else if CommandLine.arguments.count == 2 && (CommandLine.arguments[1] == "--help" || CommandLine.arguments[1] == "--experimental-dump-help") { - // Allow the showing of help information + } else if CommandLine.arguments.count == 2 && ["--help", "--experimental-dump-help"].contains(CommandLine.arguments[1]) { + // Just print help information. await Swiftly.main() return } else { - // We've been invoked outside the "init" subcommand and we're not yet configured. // This will throw if the configuration couldn't be loaded and give the user an actionable message. throw err }