Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conflict between "ls -l" and "init -l" #391

Merged
merged 3 commits into from
Jul 24, 2018
Merged

Fix conflict between "ls -l" and "init -l" #391

merged 3 commits into from
Jul 24, 2018

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Jul 23, 2018

  • Set up the .option on list and not at the root to avoid conflict.
  • Update "Getting Started" to use "ls -l"
  • Use command aliases so that yargs will recognize
    "ls" as a command (also allows "cdk ls --help" to work).
  • Upgrade to yargs 12.0.1
  • Use command aliases for "synth" as well

Fixes #389
Fixes #388
Related to #380

* Set up the `.option` on `list` and not at the root to avoid conflict.
* Update "Getting Started" to use "ls -l"
* Use command aliases so that yargs will recognize
  "ls" as a command (also allows "cdk ls --help" to work).
* Upgrade to yargs 12.0.1
* Use command aliases for "synth" as well
@eladb eladb requested a review from RomainMuller July 23, 2018 15:58
@@ -51,10 +51,10 @@ async function parseCommandLineArguments() {
.option('json', { type: 'boolean', alias: 'j', desc: 'Use JSON output instead of YAML' })
.option('verbose', { type: 'boolean', alias: 'v', desc: 'Show debug logs' })
.demandCommand(1)
.command('list', 'Lists all stacks in the cloud executable (alias: ls)')
.option('long', { type: 'boolean', default: false, alias: 'l', desc: 'display environment information for each stack' })
.command([ 'ls', 'list' ], 'Lists all stacks in the app (alias: ls)', yargs => yargs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not going to cause "alias: ls" to be output twice? (once because it's literally here, and once by yargs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output where? In the help? No.

This is how cdk --help looks like now:

Usage: cdk -a <cdk-app> COMMAND

Commands:
  cdk list                        Lists all stacks in the app      [aliases: ls]
  cdk synthesize [STACKS..]       Synthesizes and prints the CloudFormation
                                  template for this stack       [aliases: synth]
  cdk bootstrap [ENVIRONMENTS..]  Deploys the CDK toolkit stack into an AWS
                                  environment
  cdk deploy [STACKS...]          Deploys the stack(s) named STACKS into your
                                  AWS account
  cdk destroy [STACKS...]         Destroy the stack(s) named STACKS
  cdk diff [STACK]                Compares the specified stack with the deployed
                                  stack or a local template file
  cdk metadata [STACK]            Returns all metadata associated with this
                                  stack
  cdk init [TEMPLATE]             Create a new, empty CDK project from a
                                  template. Invoked without TEMPLATE, the app
                                  template will be used.
  cdk docs                        Opens the documentation in a browser
                                                                  [aliases: doc]
  cdk doctor                      Check your set-up for potential problems

Options:
  --help           Show help                                           [boolean]
  --app, -a        REQUIRED: Command-line for executing your CDK app (e.g. "node
                   bin/my-app.js")                                      [string]
  --context, -c    Add contextual string parameter.                      [array]
  --plugin, -p     Name or path of a node package that extend the CDK features.
                   Can be specified multiple times                       [array]
  --rename         Rename stack name if different then the one defined in the
                   cloud executable                                     [string]
  --trace          Print trace for stack warnings                      [boolean]
  --strict         Do not construct stacks with warnings               [boolean]
  --ignore-errors  Ignores synthesis errors, which will likely produce an
                   invalid output                     [boolean] [default: false]
  --json, -j       Use JSON output instead of YAML                     [boolean]
  --verbose, -v    Show debug logs                                     [boolean]
  --version        Show version number                                 [boolean]

If your app has a single stack, there is no need to specify the stack name

If one of cdk.json or ~/.cdk.json exists, options specified there will be used
as defaults. Settings in cdk.json take precedence.

Not enough non-option arguments: got 0, need at least 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the code in the PR has the description for list as: "Lists all stacks in the app (alias: ls)", however your command output has "Lists all stacks in the app [aliases: ls]".

Given the code, I would have expected it to look as:

cdk ls                          Lists all stacks in the app (alias: ls) [aliases: list]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a subsequent commit

// tslint:disable-next-line:max-line-length
.command('synth [STACKS..]', 'Synthesizes and prints the cloud formation template for this stack (alias: synthesize, construct, cons)', yargs => yargs
.command(['synth [STACKS..]', 'synthesize [STACKS...]', 'construct [STACKS...]', 'cons [STACKS...]'], 'Synthesizes and prints the CloudFormation template for this stack', yargs => yargs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote against cons & construct here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Elad Ben-Israel added 2 commits July 24, 2018 04:28
 * Remove "construct" and "cons" as aliases for synth
 * Switches "list" and "ls" so the help shows "list" as primary and "ls" as an alias
Probably changed in new yargs version
@eladb eladb merged commit 3b5920c into master Jul 24, 2018
@eladb eladb deleted the benisrae/llong branch July 24, 2018 03:36
@NGL321 NGL321 added the contribution/core This is a PR that came from AWS. label Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix "cdk ls" in getting started Toolkit: cannot specify language for CDK init
3 participants