go/pkg/cli/app.go

126 lines
3.3 KiB
Go
Raw Normal View History

package cli
2025-10-27 05:07:22 +00:00
import (
Implement panic recovery and graceful service retrieval (#316) * Implement panic recovery and graceful error handling for services - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with formatting fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed formatting issues in `pkg/cli/runtime.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with CI fixes) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed `auto-merge.yml` workflow by inlining logic and adding the `--repo` flag to the `gh` command. - Applied formatting to `pkg/io/local/client.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling (final fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Reverted unrelated changes to `auto-merge.yml`. - Fixed formatting issues in `pkg/io/local/client.go`. - Verified all call sites and tests. * fix: address code review comments - Add deprecation notices to MustServiceFor functions in core and framework packages to clarify they no longer panic per Go naming conventions - Update process/types.go example to show proper error handling instead of discarding errors with blank identifier - Add comprehensive test coverage for panic recovery mechanism in app.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 07:52:23 +00:00
"fmt"
"os"
Implement panic recovery and graceful service retrieval (#316) * Implement panic recovery and graceful error handling for services - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with formatting fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed formatting issues in `pkg/cli/runtime.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with CI fixes) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed `auto-merge.yml` workflow by inlining logic and adding the `--repo` flag to the `gh` command. - Applied formatting to `pkg/io/local/client.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling (final fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Reverted unrelated changes to `auto-merge.yml`. - Fixed formatting issues in `pkg/io/local/client.go`. - Verified all call sites and tests. * fix: address code review comments - Add deprecation notices to MustServiceFor functions in core and framework packages to clarify they no longer panic per Go naming conventions - Update process/types.go example to show proper error handling instead of discarding errors with blank identifier - Add comprehensive test coverage for panic recovery mechanism in app.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 07:52:23 +00:00
"runtime/debug"
Implement Authentication and Authorization Features (#314) * Implement authentication and authorization features - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP service in pkg/crypt/openpgp/service_test.go This implementation aligns the codebase with the features described in the README, providing a foundation for secure, encrypted workspaces and PGP key management. * Implement authentication and authorization features with fixes - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support This implementation provides the secure, encrypted workspace manager features described in the README. * Implement authentication and authorization features (Final) - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support - Fix formatting and unused imports This implementation provides the secure, encrypted workspace manager features described in the README. * Fix CI failure and implement auth features - Fix auto-merge workflow by implementing it locally with proper repository context - Implement Workspace and Crypt interfaces and services - Add unit tests and IPC handlers for new services - Fix formatting and unused imports in modified files - Fix PGP key serialization and decryption issues --------- Co-authored-by: Claude <developers@lethean.io>
2026-02-05 06:55:50 +00:00
"github.com/host-uk/core/pkg/crypt/openpgp"
"github.com/host-uk/core/pkg/framework"
"github.com/host-uk/core/pkg/log"
Implement Authentication and Authorization Features (#314) * Implement authentication and authorization features - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP service in pkg/crypt/openpgp/service_test.go This implementation aligns the codebase with the features described in the README, providing a foundation for secure, encrypted workspaces and PGP key management. * Implement authentication and authorization features with fixes - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support This implementation provides the secure, encrypted workspace manager features described in the README. * Implement authentication and authorization features (Final) - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support - Fix formatting and unused imports This implementation provides the secure, encrypted workspace manager features described in the README. * Fix CI failure and implement auth features - Fix auto-merge workflow by implementing it locally with proper repository context - Implement Workspace and Crypt interfaces and services - Add unit tests and IPC handlers for new services - Fix formatting and unused imports in modified files - Fix PGP key serialization and decryption issues --------- Co-authored-by: Claude <developers@lethean.io>
2026-02-05 06:55:50 +00:00
"github.com/host-uk/core/pkg/workspace"
"github.com/spf13/cobra"
2025-10-27 05:07:22 +00:00
)
const (
// AppName is the CLI application name.
AppName = "core"
)
// AppVersion is set at build time via ldflags:
//
// go build -ldflags="-X github.com/host-uk/core/pkg/cli.AppVersion=v1.0.0"
var AppVersion = "dev"
// Main initialises and runs the CLI application.
// This is the main entry point for the CLI.
Implement panic recovery and graceful service retrieval (#316) * Implement panic recovery and graceful error handling for services - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with formatting fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed formatting issues in `pkg/cli/runtime.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with CI fixes) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed `auto-merge.yml` workflow by inlining logic and adding the `--repo` flag to the `gh` command. - Applied formatting to `pkg/io/local/client.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling (final fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Reverted unrelated changes to `auto-merge.yml`. - Fixed formatting issues in `pkg/io/local/client.go`. - Verified all call sites and tests. * fix: address code review comments - Add deprecation notices to MustServiceFor functions in core and framework packages to clarify they no longer panic per Go naming conventions - Update process/types.go example to show proper error handling instead of discarding errors with blank identifier - Add comprehensive test coverage for panic recovery mechanism in app.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 07:52:23 +00:00
// Exits with code 1 on error or panic.
func Main() {
Implement panic recovery and graceful service retrieval (#316) * Implement panic recovery and graceful error handling for services - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with formatting fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed formatting issues in `pkg/cli/runtime.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling for services (with CI fixes) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Fixed `auto-merge.yml` workflow by inlining logic and adding the `--repo` flag to the `gh` command. - Applied formatting to `pkg/io/local/client.go`. - Updated all relevant tests and call sites. * Implement panic recovery and graceful error handling (final fix) - Added panic recovery to CLI entry point (`Main`) with logging and stack traces. - Refactored `MustServiceFor`, `Config()`, and `Display()` to return errors instead of panicking. - Updated `CLAUDE.md` to reflect the service retrieval API change. - Made `signalService.OnShutdown` idempotent to prevent panics during redundant shutdowns. - Reverted unrelated changes to `auto-merge.yml`. - Fixed formatting issues in `pkg/io/local/client.go`. - Verified all call sites and tests. * fix: address code review comments - Add deprecation notices to MustServiceFor functions in core and framework packages to clarify they no longer panic per Go naming conventions - Update process/types.go example to show proper error handling instead of discarding errors with blank identifier - Add comprehensive test coverage for panic recovery mechanism in app.go Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 07:52:23 +00:00
// Recovery from panics
defer func() {
if r := recover(); r != nil {
log.Error("recovered from panic", "error", r, "stack", string(debug.Stack()))
Shutdown()
Fatal(fmt.Errorf("panic: %v", r))
}
}()
// Initialise CLI runtime with services
if err := Init(Options{
AppName: AppName,
Version: AppVersion,
Services: []framework.Option{
framework.WithName("i18n", NewI18nService(I18nOptions{})),
framework.WithName("log", NewLogService(log.Options{
Level: log.LevelInfo,
})),
Implement Authentication and Authorization Features (#314) * Implement authentication and authorization features - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP service in pkg/crypt/openpgp/service_test.go This implementation aligns the codebase with the features described in the README, providing a foundation for secure, encrypted workspaces and PGP key management. * Implement authentication and authorization features with fixes - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support This implementation provides the secure, encrypted workspace manager features described in the README. * Implement authentication and authorization features (Final) - Define Workspace and Crypt interfaces in pkg/framework/core/interfaces.go - Add Workspace() and Crypt() methods to Core in pkg/framework/core/core.go - Implement PGP service in pkg/crypt/openpgp/service.go using ProtonMail go-crypto - Implement Workspace service in pkg/workspace/service.go with encrypted directory structure - Register new services in pkg/cli/app.go with proper service names ('crypt', 'workspace') - Add IPC handlers to both services for frontend/CLI communication - Add unit tests for PGP and Workspace services - Fix panic in PGP key serialization by using manual packet serialization - Fix PGP decryption by adding armor decoding support - Fix formatting and unused imports This implementation provides the secure, encrypted workspace manager features described in the README. * Fix CI failure and implement auth features - Fix auto-merge workflow by implementing it locally with proper repository context - Implement Workspace and Crypt interfaces and services - Add unit tests and IPC handlers for new services - Fix formatting and unused imports in modified files - Fix PGP key serialization and decryption issues --------- Co-authored-by: Claude <developers@lethean.io>
2026-02-05 06:55:50 +00:00
framework.WithName("crypt", openpgp.New),
framework.WithName("workspace", workspace.New),
},
}); err != nil {
Standardize CLI Error Handling (#318) * Standardize CLI error handling and deprecate cli.Fatal - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. * Fix CI failure: remove unused fmt import in pkg/mcp/transport_tcp.go - Removed unused "fmt" import in `pkg/mcp/transport_tcp.go` that was causing CI failure. - Verified build and relevant tests pass. * Standardize CLI error handling and fix formatting issues - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. - Fixed formatting in `pkg/io/local/client.go`. - Removed unused `fmt` import in `pkg/mcp/transport_tcp.go`. * Standardize CLI error handling and fix CI issues - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. - Fixed formatting in `pkg/io/local/client.go`. - Removed unused `fmt` import in `pkg/mcp/transport_tcp.go`. - Fixed potential `gh` context issue in `.github/workflows/auto-merge.yml` by providing `GH_REPO`. --------- Co-authored-by: Claude <developers@lethean.io>
2026-02-05 06:55:49 +00:00
Error(err.Error())
os.Exit(1)
}
defer Shutdown()
// Add completion command to the CLI's root
RootCmd().AddCommand(completionCmd)
Standardize CLI Error Handling (#318) * Standardize CLI error handling and deprecate cli.Fatal - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. * Fix CI failure: remove unused fmt import in pkg/mcp/transport_tcp.go - Removed unused "fmt" import in `pkg/mcp/transport_tcp.go` that was causing CI failure. - Verified build and relevant tests pass. * Standardize CLI error handling and fix formatting issues - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. - Fixed formatting in `pkg/io/local/client.go`. - Removed unused `fmt` import in `pkg/mcp/transport_tcp.go`. * Standardize CLI error handling and fix CI issues - Updated `pkg/cli/output.go` to send error and warning output to `os.Stderr`. - Added `ErrorWrap`, `ErrorWrapVerb`, and `ErrorWrapAction` helpers to `pkg/cli/output.go`. - Deprecated `cli.Fatal` family of functions in `pkg/cli/errors.go`. - Introduced `cli.ExitError` and `cli.Exit` helper to allow commands to return specific exit codes. - Updated `pkg/cli/app.go` to silence Cobra errors and handle error printing and process exit in `Main`. - Refactored multiple commands (QA, SDK, CI, Updater) to return errors instead of exiting abruptly. - Replaced direct `os.Stderr` writes with standardized CLI or log helpers across the codebase. - Updated tests to accommodate changes in output destination. - Fixed formatting in `pkg/io/local/client.go`. - Removed unused `fmt` import in `pkg/mcp/transport_tcp.go`. - Fixed potential `gh` context issue in `.github/workflows/auto-merge.yml` by providing `GH_REPO`. --------- Co-authored-by: Claude <developers@lethean.io>
2026-02-05 06:55:49 +00:00
if err := Execute(); err != nil {
code := 1
var exitErr *ExitError
if As(err, &exitErr) {
code = exitErr.Code
}
Error(err.Error())
os.Exit(code)
}
}
// completionCmd generates shell completion scripts.
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate shell completion script",
Long: `Generate shell completion script for the specified shell.
To load completions:
Bash:
$ source <(core completion bash)
# To load completions for each session, execute once:
# Linux:
$ core completion bash > /etc/bash_completion.d/core
# macOS:
$ core completion bash > $(brew --prefix)/etc/bash_completion.d/core
Zsh:
# If shell completion is not already enabled in your environment,
# you will need to enable it. You can execute the following once:
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
# To load completions for each session, execute once:
$ core completion zsh > "${fpath[1]}/_core"
# You will need to start a new shell for this setup to take effect.
Fish:
$ core completion fish | source
# To load completions for each session, execute once:
$ core completion fish > ~/.config/fish/completions/core.fish
PowerShell:
PS> core completion powershell | Out-String | Invoke-Expression
# To load completions for every new session, run:
PS> core completion powershell > core.ps1
# and source this file from your PowerShell profile.
`,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
_ = cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
_ = cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
_ = cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
_ = cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
}
},
2025-10-27 05:07:22 +00:00
}