iterative / shtab

↔️ Automagic shell tab completion for Python CLI applications
https://docs.iterative.ai/shtab
Other
363 stars 35 forks source link

tcsh: Fix autocompletion for no single-hyphen args #112

Closed simaoafonso-pwt closed 1 year ago

simaoafonso-pwt commented 1 year ago

If the parser has no single-hyphen options, the tcsh template would generate a syntax error.

Include a hack to that the autocompletion for the double-hyphen selection does not add an extra space at the end.


Another fix to the tcsh template support, see #56 #57 #58

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.53%.

Quality metrics Before After Change
Complexity 47.11 ⛔ 48.02 ⛔ 0.91 👎
Method Length 136.70 😞 137.95 😞 1.25 👎
Working memory 1.67 ⭐ 1.65 ⭐ -0.02 👍
Quality 25.93% 😞 25.40% 😞 -0.53% 👎
Other metrics Before After Change
Lines 763 771 8
Changed files Quality Before Quality After Quality Change
shtab/init.py 25.93% 😞 25.40% 😞 -0.53% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
shtab/init.py get_bash_commands 78 ⛔ 590 ⛔ 1.22% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
shtab/init.py complete_zsh 62 ⛔ 910 ⛔ 2.38% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
shtab/init.py complete_tcsh 57 ⛔ 493 ⛔ 3.96% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
shtab/init.py complete_bash 2 ⭐ 106 🙂 11 😞 64.30% 🙂 Extract out complex expressions
shtab/init.py add_argument_to 4 ⭐ 89 🙂 11 😞 64.67% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 66.66% and project coverage change: -0.19 :warning:

Comparison is base (ed933a6) 91.06% compared to head (336c7ad) 90.88%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #112 +/- ## ========================================== - Coverage 91.06% 90.88% -0.19% ========================================== Files 3 3 Lines 347 351 +4 ========================================== + Hits 316 319 +3 - Misses 31 32 +1 ``` | [Impacted Files](https://app.codecov.io/gh/iterative/shtab/pull/112?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iterative) | Coverage Δ | | |---|---|---| | [shtab/\_\_init\_\_.py](https://app.codecov.io/gh/iterative/shtab/pull/112?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=iterative#diff-c2h0YWIvX19pbml0X18ucHk=) | `93.11% <66.66%> (-0.25%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

simaoafonso-pwt commented 1 year ago

This seems to break things a little (at least on bash).

That's weird, I only changed the csh function, and this commit to avoid test failures.

b05c0c76dd114deb103484e0d4dab2e6f312d9bf

I should rebase and retest this.

simaoafonso-pwt commented 1 year ago

Rebased and re-tested, including that test you mentioned, works for me.

simaoafonso-pwt commented 1 year ago

Rebased and re-tested, including that test you mentioned, works for me.

Sounds like the test failure is not my fault, pydoc-markdown cannot run correctly on PyPy?

casperdcl commented 1 year ago

Thanks! Rebased now over #139 (should merge that first). Better now?

simaoafonso-pwt commented 1 year ago

LGTM, you can merge this.