From 5e0d4d0f05a7a7b4f562fd7896baf05005835c0c Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Fri, 2 Jan 2026 01:23:42 +0100 Subject: [PATCH] build: Generate CLI docs in GHA (#236) * build: Generate CLI docs in GHA * fix: Move no-tty logic outside cobra definitions --- .github/workflows/go-tests.yml | 6 ++++++ cmd/uncloud/service/exec.go | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index aed6bb34..84190f0d 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -36,6 +36,12 @@ jobs: git diff --exit-code || (echo "go.mod or go.sum has changed. Please run 'go mod tidy' and commit the changes." && exit 1) + - name: Generate docs + run: | + make cli-docs + git diff --exit-code || + (echo "Documentation is out of date. Please run 'make cli-docs' and commit the changes." && exit 1) + - name: Run tests run: | make ucind-image diff --git a/cmd/uncloud/service/exec.go b/cmd/uncloud/service/exec.go index ac274049..2712b1ca 100644 --- a/cmd/uncloud/service/exec.go +++ b/cmd/uncloud/service/exec.go @@ -59,7 +59,7 @@ If the service has multiple replicas and no container ID is specified, the comma execCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: run command in the background") - execCmd.Flags().BoolVarP(&opts.noTty, "no-tty", "T", !cli.IsStdoutTerminal(), + execCmd.Flags().BoolVarP(&opts.noTty, "no-tty", "T", false, "Disable pseudo-TTY allocation. By default 'uc exec' allocates a TTY when connected to a terminal.") // Keep "-i" and "-t" flags hidden for compatibility with docker exec @@ -82,6 +82,11 @@ If the service has multiple replicas and no container ID is specified, the comma } func runExec(ctx context.Context, uncli *cli.CLI, serviceName string, command []string, opts execCliOptions) error { + // Disable TTY allocation if not connected to a terminal + if !cli.IsStdoutTerminal() { + opts.noTty = true + } + if !opts.detach { // Check if we're trying to attach to a TTY from a non-TTY client, e.g. // when doing an 'cmd | uc exec ...'