From 146ad502951971e3d0195afd2d93bad9d34cdf20 Mon Sep 17 00:00:00 2001 From: NightStar Date: Tue, 28 Jul 2026 16:12:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20completion=20+=20README=20=E2=80=94=20p?= =?UTF-8?q?olish=20and=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++ internal/cmd/root.go | 20 ++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8f44932 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# ry — Multi-Cloud CLI + +A `gh`-style CLI for managing cloud resources across providers. + +## Install + +```bash +go install git.yoresee.cc/nightstar/ry/cmd/ry@latest +``` + +## Quick Start + +```bash +ry provider add rainyun +# Enter your API key when prompted + +ry server list +ry server start +ry server vnc +``` + +## Commands + +- `ry provider` — manage cloud providers (add, use, list) +- `ry server` — manage cloud servers (list, get, start, stop, reboot, reinstall, reset-password, vnc) +- `ry domain` — manage domains and DNS records +- `ry storage` — manage object storage and buckets +- `ry billing` — view orders +- `ry config` — manage configuration (show, set, path) +- `ry completion` — shell completion for bash/zsh/fish + +## Global Flags + +| Flag | Description | +|------|-------------| +| `-p, --provider` | Override cloud provider | +| `-o, --output` | Output format: table, json, yaml | +| `--raw` | Raw API response | +| `--debug` | Debug output | + +## Supported Providers + +- **雨云 (Rainyun)** — full support +- More coming soon + +## Config + +`~/.config/ry/config.toml` diff --git a/internal/cmd/root.go b/internal/cmd/root.go index e301a19..09c1511 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -88,4 +88,24 @@ func init() { rootCmd.PersistentFlags().StringVarP(&flagOutput, "output", "o", "", "Output format: table, json, yaml, raw") rootCmd.PersistentFlags().BoolVar(&flagRaw, "raw", false, "Output raw API response") rootCmd.PersistentFlags().BoolVar(&flagDebug, "debug", false, "Enable debug output") + + completionCmd := &cobra.Command{ + Use: "completion [bash|zsh|fish]", + Short: "Generate shell completion script", + Annotations: map[string]string{"skipProvider": "true"}, + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + switch args[0] { + case "bash": + return rootCmd.GenBashCompletion(os.Stdout) + case "zsh": + return rootCmd.GenZshCompletion(os.Stdout) + case "fish": + return rootCmd.GenFishCompletion(os.Stdout, true) + default: + return fmt.Errorf("unsupported shell: %s", args[0]) + } + }, + } + rootCmd.AddCommand(completionCmd) }