fastly / cli

Build, deploy and configure Fastly services from your terminal
https://fastly.dev/reference/cli/
Apache License 2.0
139 stars 59 forks source link

[FEATURE REQUEST] Include product internal name in `fastly products` output #1251

Closed harmony7 closed 2 months ago

harmony7 commented 3 months ago

Problem

Whenever I need to see which self-service products are available and/or current statuses for a fastly service, I use the fastly products command line and I am given output that looks like the following, which lists the products by their "friendly name":

% fastly products
PRODUCT            ENABLED
Brotli Compression  false
Domain Inspector    false
Fanout              false
Image Optimizer     false
Origin Inspector    false
Web Sockets         false

To actually enable or disable them however I need to refer to them by their internal name, which are not available in the above output.

% fastly products --enable="Image Optimizer"
ERROR: error parsing arguments: enum value must be one of brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'Image Optimizer'.

Once I get this error message I will know what to actually type:

% fastly products --enable=image_optimizer
SUCCESS: Successfully enabled product 'image_optimizer'

Proposed solution

The solution I would like would be to include the internal name in the command output, something like this:

% fastly products
PRODUCT NAME        FRIENDLY NAME            ENABLED
brotli_compression  Brotli Compression  false
domain_inspector    Domain Inspector    false
fanout              Fanout              false
image_optimizer     Image Optimizer     false
origin_inspector    Origin Inspector    false
websockets          Web Sockets         false

Workaround

By the way, as a workaround you can currently use the --json output to get output including just the internal names:

% fastly products --json
{
  "brotli_compression": false,
  "domain_inspector": false,
  "fanout": false,
  "image_optimizer": false,
  "origin_inspector": false,
  "websockets": false
}
Integralist commented 3 months ago

👋🏻

I agree it would be nice to expose the enum inputs but that feels like a lot of extra visual noise because they are pretty much the same except for lowercase/underscores.

I would say, have the product names only show when --verbose is set but that also isn't ideal.

Another option might be to just replace the friendly name with the product name, less duplication and is easily copy/pastable.

Another option might be to have a mapping between the friendly name and the enum (e.g. allow friendly name to be provided, and then see if it can be converted to a product name and matched). The downside of this is the implementation would have to change from being an 'enum flag' to a basic 'string flag' and you lose some type safety.

So if I had to choose I'd say just replace the friendly name output with the enum variant.