mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-12-06 04:56:33 +08:00
feat(cli): add --gw and --ws aliases for --gateway and --workspace (#6202)
* feat(cli): add --gw and --ws aliases for --gateway and --workspace Closes #6200 Signed-off-by: Jim Meyer <jimeyer@nvidia.com> * docs(cli): reword gateway and workspace alias mentions Signed-off-by: Jim Meyer <jimeyer@nvidia.com> --------- Signed-off-by: Jim Meyer <jimeyer@nvidia.com>
This commit is contained in:
@@ -470,6 +470,7 @@ struct Cli {
|
||||
/// Gateway name to operate on (resolved from stored metadata).
|
||||
#[arg(
|
||||
long,
|
||||
visible_alias = "gw",
|
||||
short = 'g',
|
||||
global = true,
|
||||
env = "OPENSHELL_GATEWAY",
|
||||
@@ -500,6 +501,7 @@ struct Cli {
|
||||
/// Workspace scope for resource operations.
|
||||
#[arg(
|
||||
long,
|
||||
visible_alias = "ws",
|
||||
global = true,
|
||||
env = "OPENSHELL_WORKSPACE",
|
||||
default_value = "default",
|
||||
@@ -4644,6 +4646,35 @@ mod tests {
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
|
||||
#[test]
|
||||
fn gateway_and_workspace_flag_aliases_parse() {
|
||||
let cli = Cli::try_parse_from([
|
||||
"openshell",
|
||||
"--gw",
|
||||
"prod",
|
||||
"--ws",
|
||||
"team-a",
|
||||
"sandbox",
|
||||
"list",
|
||||
])
|
||||
.expect("aliases should parse before the subcommand");
|
||||
assert_eq!(cli.gateway.as_deref(), Some("prod"));
|
||||
assert_eq!(cli.workspace, "team-a");
|
||||
|
||||
let cli = Cli::try_parse_from([
|
||||
"openshell",
|
||||
"sandbox",
|
||||
"list",
|
||||
"--gw",
|
||||
"prod",
|
||||
"--ws",
|
||||
"team-a",
|
||||
])
|
||||
.expect("aliases should parse after the subcommand");
|
||||
assert_eq!(cli.gateway.as_deref(), Some("prod"));
|
||||
assert_eq!(cli.workspace, "team-a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn policy_update_parses_explicit_l7_scope_and_endpoint_path() {
|
||||
let cli = Cli::try_parse_from([
|
||||
|
||||
@@ -107,7 +107,7 @@ Switch the active gateway:
|
||||
openshell gateway select production
|
||||
```
|
||||
|
||||
Override the active gateway for a single command with `-g`:
|
||||
Override the active gateway for a single command with `--gateway` (`-g` or `--gw` for short):
|
||||
|
||||
```shell
|
||||
openshell status -g staging
|
||||
|
||||
@@ -170,8 +170,8 @@ change labels after creation.
|
||||
|
||||
## Target a Workspace
|
||||
|
||||
Pass `--workspace` to scope a resource operation. The flag is global, so it
|
||||
can appear before or after the subcommand.
|
||||
Pass `--workspace` (or `--ws`) to scope a resource operation. The flag is
|
||||
global, so it can appear before or after the subcommand.
|
||||
|
||||
```shell
|
||||
openshell sandbox list --workspace team-ml
|
||||
|
||||
Reference in New Issue
Block a user