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

CP-1794 Add completions.dart support #151

Merged
merged 5 commits into from
May 18, 2016

Conversation

georgelesica-wf
Copy link
Contributor

@georgelesica-wf georgelesica-wf commented May 3, 2016

This addresses #103. I've added basic support for generating the completion file using completions.dart.

See the README for information on how to consume the new completions.

The script even works with custom project-specific tasks because it operates by adding a pseudo command to ddev that effectively introspects its current configuration. This means the script won't actually need updating all that often. In the future we may not even need to store the script, we may just generate it on the fly from completions.dart.

Code Review / +10

Follow the instructions in the README to get it working. Then make sure it works.

Install globally using pub global activate -s /path/to/clone instead of the command in the README since that would just install the release version. Of particular use would be testing in zsh since I don't use it.

The completions only work within a project, see the readme for how to set up the ddev alias, which is required. Link this branch into a random Dart project, pub upgrade, and then you should have completions when you do ddev <tab> <tab> <tab>....

Review:

@evanweible-wf
@maxwellpeterson-wf
@jayudey-wf

@@ -101,7 +101,7 @@ Future _run(List<String> args) async {

ArgResults env;
try {
env = _parser.parse(args);
env = tryArgsCompletion(args, _parser);
Copy link
Contributor

Choose a reason for hiding this comment

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

So does this just try add support for parsing incomplete args? Like if someone were to accidentally run ddev form - it would run ddev format?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't read through the full source, but it seems like it basically just adds a new command that provides completions. The completion script is then almost entirely generic in that it just runs a special version of ddev itself to get the completions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok I see 👍

@georgelesica-wf
Copy link
Contributor Author

The one drawback here is that the completions are pretty slow because dart_dev essentially has to run every time it needs to do a completion. Which isn't great since there is quite a bit of "stuff" done at startup.

@evanweible-wf
Copy link
Contributor

@georgelesica-wf just pulled it down to test it out, it is pretty slow.. is there anyway we could provide an alternate code path for completion to speed it up?

@georgelesica-wf
Copy link
Contributor Author

@evanweible-wf I'll look into it, I agree the (lack of) speed is annoying.

@georgelesica-wf
Copy link
Contributor Author

@evanweible-wf upon investigation, it is already short-circuiting for us (https://github.com/kevmoo/completion.dart/blob/master/lib/src/try_completion.dart#L69) so I was wrong about why it is slow. The only setup we're doing before it takes control is registering all our commands with the arg parser, which is necessary. I'm not entirely sure, now, why completion is so slow.

@evanweible-wf
Copy link
Contributor

@georgelesica-wf we can revisit performance at a later time - this is definitely the more maintainable approach so I'm good with it.

+1

@trentgrover-wf
Copy link
Contributor

+1

1 similar comment
@maxwellpeterson-wf
Copy link
Member

+1

@evanweible-wf
Copy link
Contributor

@jayudey-wf ready for merge

@jayudey-wf jayudey-wf changed the title Add completions.dart support CP-1794 Add completions.dart support May 17, 2016
@georgelesica-wf
Copy link
Contributor Author

@jayudey-wf I updated the PR and rebuilt the completion script so it should be unambiguous now as to when the completions will work. Spoiler: only in a project, not globally.

@jayudey-wf
Copy link
Contributor

+5 i've verified that it's working as expected with bash but I am currently un-able to verify it's working as expected within zsh

@evanweible-wf
Copy link
Contributor

@jayudey-wf I'll test with zsh

@evanweible-wf
Copy link
Contributor

+5

  • completions work with zsh when setup according to the README instructions

@jayudey-wf ready for merge

@jayudey-wf
Copy link
Contributor

jayudey-wf commented May 18, 2016

QA Resource Approval: +1

  • Testing instruction
  • Dev +1's
  • Dev/QA +10 with detail of what was tested
    • performed and documented by Evan and Jay
  • Unit test created/updated
  • All unit tests pass

Merging into master.

@evanweible-wf
Copy link
Contributor

+1

@jayudey-wf
Copy link
Contributor

Manual CI on dart 1.15.0

  • pub run dart_dev format
  • pub run dart_dev analyze
  • pub run dart_dev test --integration
  • pub run dart_dev coverage --integration

@jayudey-wf jayudey-wf merged commit ad45bf7 into Workiva:master May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants