fleet/changes/36702-fix-fleetctl-config-help
edwardsb 37a2547e79
Fix fleetctl config help display for missing arguments (#37769)
Replace cli.ShowCommandHelp with cli.ShowSubcommandHelp to properly show
usage information when fleetctl config get/set are called without
required arguments. Previously displayed confusing "No help topic for
'get'" error, now shows helpful command help matching --help behavior.
Fixes #36702

## Fix: `fleetctl config get/set` now shows helpful usage information

Fixed the issue where running `fleetctl config get` or `fleetctl config
set` without proper arguments would show a confusing error message.
These commands now display helpful usage information, matching the
behavior of `--help`.

### Before the fix

Running `fleetctl config get` without arguments:

```bash
$ fleetctl config get
Error: No help topic for 'get'
exit status 1
```

### After the fix

Now running the same commands shows helpful usage information:

#### `fleetctl config get` (without arguments)

```bash
$ fleetctl config get
NAME:
   fleetctl config get - Get a config option

USAGE:
   fleetctl config get [options]

OPTIONS:
   --config value   Path to the fleetctl config file (default: "/home/ben/.fleet/config") [$CONFIG]
   --context value  Name of fleetctl config context to use (default: "default") [$CONTEXT]
   --help, -h       show help
```

#### `fleetctl config get invalidkey` (invalid key)

```bash
$ fleetctl config get invalidkey
NAME:
   fleetctl config get - Get a config option

USAGE:
   fleetctl config get [options]

OPTIONS:
   --config value   Path to the fleetctl config file (default: "/home/ben/.fleet/config") [$CONFIG]
   --context value  Name of fleetctl config context to use (default: "default") [$CONTEXT]
   --help, -h       show help
```

#### `fleetctl config set` (without flags)

```bash
$ fleetctl config set
NAME:
   fleetctl config set - Set config options

USAGE:
   fleetctl config set [options]

OPTIONS:
   --config value                                   Path to the fleetctl config file (default: "/home/ben/.fleet/config") [$CONFIG]
   --context value                                  Name of fleetctl config context to use (default: "default") [$CONTEXT]
   --address value                                  Address of the Fleet server [$ADDRESS]
   --email value                                    Email to use when connecting to the Fleet server [$EMAIL]
   --token value                                    Fleet API token [$TOKEN]
   --tls-skip-verify                                Skip TLS certificate validation (default: false) [$INSECURE]
   --rootca value                                   Specify RootCA chain used to communicate with Fleet [$ROOTCA]
   --url-prefix value                               Specify URL Prefix to use with Fleet server (copy from server configuration) [$URL_PREFIX]
   --custom-header value [ --custom-header value ]  Specify a custom header as 'Header:Value' to be set on every request to the Fleet server (can be specified multiple times for multiple headers, note that this replaces any existing custom headers). Note that when using the environment variable to set this option, it must be set like so: 'CUSTOM_HEADER=Header:Value,Header:Value', and the value cannot contain commas. [$CUSTOM_HEADER]
   --help, -h                                       show help
```

#### Normal operation still works as expected

```bash
$ fleetctl config get address
  default.address => http://test.local

$ fleetctl config get --help
NAME:
   fleetctl config get - Get a config option

USAGE:
   fleetctl config get [options]

OPTIONS:
   --config value   Path to the fleetctl config file (default: "/home/ben/.fleet/config") [$CONFIG]
   --context value  Name of fleetctl config context to use (default: "default") [$CONTEXT]
   --help, -h       show help
```


**Related issue:** Resolves #36702

# Checklist for submitter

If some of the following don't apply, delete the relevant line.

## Testing

- [X] Added/updated automated tests

- [X] QA'd all new/changed functionality manually
2026-01-08 09:55:18 -05:00

1 line
104 B
Text

- Fixed fleetctl config get/set to show proper usage information when called without required arguments