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

Autocompletion #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

NoFr1ends
Copy link

Fix #9

Implement basic functionallity for generating bash/zsh autocompletion script.

Note: The implementation of Delegate:toAutoCompletion is maybe not the best way to do this. But I needed a way to access the optionNames.

@codecov-io
Copy link

codecov-io commented Aug 8, 2017

Codecov Report

Merging #22 into master will increase coverage by 1.02%.
The diff coverage is 93.93%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #22      +/-   ##
============================================
+ Coverage     81.79%   82.82%   +1.02%     
- Complexity      137      143       +6     
============================================
  Files            11       12       +1     
  Lines           357      390      +33     
  Branches         72       73       +1     
============================================
+ Hits            292      323      +31     
- Misses           30       32       +2     
  Partials         35       35
Impacted Files Coverage Δ Complexity Δ
...in/com/xenomachina/argparser/PositionalDelegate.kt 61.53% <0%> (-5.13%) 9 <0> (ø)
...tlin/com/xenomachina/argparser/WrappingDelegate.kt 84.61% <0%> (-7.06%) 10 <0> (ø)
...c/main/kotlin/com/xenomachina/argparser/Default.kt 82.35% <100%> (+1.1%) 0 <0> (ø) ⬇️
...main/kotlin/com/xenomachina/argparser/ArgParser.kt 84.7% <100%> (+0.46%) 53 <0> (+1) ⬆️
...kotlin/com/xenomachina/argparser/OptionDelegate.kt 85.71% <100%> (+0.52%) 18 <1> (+1) ⬆️
...ain/kotlin/com/xenomachina/argparser/Exceptions.kt 94.73% <100%> (+0.98%) 0 <0> (ø) ⬇️
...com/xenomachina/argparser/DefaultAutoCompletion.kt 100% <100%> (ø) 4 <4> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e0186a6...ee8c492. Read the comment docs.

Copy link
Owner

@xenomachina xenomachina left a comment

Choose a reason for hiding this comment

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

Sorry it took so long for me to review this. I was swamped with other stuff.

Overall, this looks great! Thank you for this contribution. I only have a few minor suggestions.

class ShowAutoCompletionException internal constructor(
private val autoCompletion: AutoCompletion,
private val delegates: List<ArgParser.Delegate<*>>
) : SystemExitException("Help was requested", 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

s/Help/Autocompletion/

@@ -0,0 +1,49 @@
// Copyright © 2016 Laurence Gonsalves
Copy link
Owner

Choose a reason for hiding this comment

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

This should be 2017 and your name.

class DefaultAutoCompletion : AutoCompletion {
override fun format(progName: String?, delegates: List<ArgParser.Delegate<*>>): String {
val sb = StringBuilder()
sb.append("_$progName()\n")
Copy link
Owner

Choose a reason for hiding this comment

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

Perhaps triple-quoted strings would make this a bit easier to read?

@xenomachina xenomachina self-assigned this Oct 31, 2017
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.

None yet

3 participants