Update help text for kubectx and kubens

- Add description strings from bash scripts to Go help output
- Add -r/--readonly usage lines to kubectx help
- Reorder help to show -s/-r flags more prominently
- Normalize flag separators to comma-space consistently

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ahmet Alp Balkan
2026-03-24 23:27:38 -04:00
parent 2b2a3bacce
commit c20f59254a
4 changed files with 17 additions and 7 deletions

View File

@@ -30,21 +30,25 @@ func (_ HelpOp) Run(stdout, _ io.Writer) error {
}
func printUsage(out io.Writer) error {
help := `USAGE:
help := `Manage and switch between kubectl contexts.
USAGE:
%PROG% : list the contexts
%PROG% <NAME> : switch to context <NAME>
%PROG% - : switch to the previous context
%PROG% -s, --shell <NAME> : start a shell scoped to context <NAME>
%PROG% -s, --shell : interactively select a context to start a shell
%PROG% -r, --readonly <NAME> : start a read-only shell for context <NAME>
%PROG% -r, --readonly : interactively select a context for read-only shell
%PROG% -c, --current : show the current context name
%PROG% -u, --unset : unset the current context
%PROG% <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
%PROG% <NEW_NAME>=. : rename current-context to <NEW_NAME>
%PROG% -u, --unset : unset the current context
%PROG% -d <NAME> [<NAME...>] : delete context <NAME> ('.' for current-context)
%SPAC% (this command won't delete the user/cluster entry
%SPAC% referenced by the context entry)
%PROG% -s, --shell <NAME> : start a shell scoped to context <NAME>
%PROG% -s, --shell : interactively select a context to start a shell
%PROG% -h,--help : show this message
%PROG% -V,--version : show version`
%PROG% -h, --help : show this message
%PROG% -V, --version : show version`
help = strings.ReplaceAll(help, "%PROG%", selfName())
help = strings.ReplaceAll(help, "%SPAC%", strings.Repeat(" ", len(selfName())))

View File

@@ -1,3 +1,5 @@
// kubectx(1) is a utility to manage and switch between kubectl contexts.
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -30,7 +30,9 @@ func (_ HelpOp) Run(stdout, _ io.Writer) error {
}
func printUsage(out io.Writer) error {
help := `USAGE:
help := `Switch between Kubernetes namespaces.
USAGE:
%PROG% : list the namespaces in the current context
%PROG% <NAME> : change the active namespace of current context
%PROG% <NAME> --force/-f : force change the active namespace of current context (even if it doesn't exist)

View File

@@ -1,3 +1,5 @@
// kubens(1) is a utility to switch between Kubernetes namespaces.
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");