dashes in CLI commands

1

Not technical but I'm just curious. Any idea why some CLI commands have dashes (-) and others do not. Is there a specific reason for this? I'm very consistent and want to understand the reasoning. Thanks...Larry

  • Thanks for the responses. Now it is clear.

質問済み 2年前462ビュー
5回答
1

Re-encrypt itself is a hyphenated word, so you'll see hyphens in those cases or if the subcommand is two words or more. Check out the s3api CLI documentation for examples.

AWS
mike
回答済み 2年前
0

Thanks that's what I was wondering. I found a few as I was going thru some training.

aws kms encrypt aws kms re-encrypt So that indicates that kms is the command and encrypt and re-encrypt are the subcommands? That's what I don't understand.

回答済み 2年前
  • Is the dash in "re-encrypt" what's throwing you off?

    Commands (kms) in this example and their sub-commands (re-encrypt) can contain dashes but will never begin with leading dashes. Its only the options that begin with dashes, which for aws kms re-encrypt are:

    aws kms re-encrypt --ciphertext-blob <value> [--source-encryption-context <value>] [--source-key-id <value>] --destination-key-id <value> [--destination-encryption-context <value>] [--source-encryption-algorithm <value>] [--destination-encryption-algorithm <value>] [--grant-tokens <value>] [--cli-input-json | --cli-input-yaml] [--generate-cli-skeleton <value>]

0

As described in Command structure in the AWS CLI, the command structure is:

$ aws <command> <subcommand> [options and parameters]

To my knowledge, none of the commands or subcommands require leading dashes, only the command/subcommand specific options require a leading double dash.

Can you provide any examples of "some CLI commands that have dashes (-)"?

AWS
Scott_K
回答済み 2年前
0
AWS
Kunal_G
回答済み 2年前
0

Hello, Larry. From your follow-up question, it is my hope that this adds to your search for clarity.

In the example of your most recent question, aws kms, in that case, follows the nomenclature of aws <service> and not of aws <command>.

To be fair, re-encrypt is a hyphenated word on its own, but to be clear, an example from aws iam list-users is used below, where list-users is the command, and is singly hyphenated. Mike has included an S3api resource as well, which describes additional instances of multiple worded subcommands that occur without a conventional service declaration.

One reason for the hyphenation between commands containing multiple words, is to prevent unnecessary whitespace between parameters, thereby avoiding conflicts in readability, etc. To add, the double hyphenation tends to occur at the beginning of another command, whether to offer a selection choice (as in file input/output type, seen below with [--cli-input-json | --cli-input-yaml]), or for the option to pass objects to a specified file location, as seen in [--generate-cli-skeleton <value>]

In the portion of the AWS CLI User Guide, [Generating an AWS CLI skeleton and input file] (https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-skeleton.html), the following is shown to illustrate that, in general, the AWS service input occurs directly after the aws declaration.

That is,

$ aws service command help

e.g. of "input":

$ aws iam list-users help
...
SYNOPSIS
          list-users
          ...
          [--cli-input-json | --cli-input-yaml]
          ...
          [--generate-cli-skeleton <value>]
...

Feel free to ask, if there are any follow-up questions!

Thank you.

Gabriel

AWS
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ