shtab icon indicating copy to clipboard operation
shtab copied to clipboard

Fix subcommands with hyphens (and periods, spaces, etc) in zsh

Open brentyi opened this issue 3 years ago • 1 comments

A call to wordify() was missing.

Example that breaks with the current version on master:

import argparse

import shtab

parser = argparse.ArgumentParser(prog="test.py")
subparsers = parser.add_subparsers()

sub1 = subparsers.add_parser("subcommand-1", help="First subcommand")
sub2 = subparsers.add_parser("subcommand-2", help="Second subcommand")


print(shtab.complete_zsh(parser))

brentyi avatar Sep 09 '22 13:09 brentyi

Sourcery Code Quality Report

Merging this PR leaves code quality unchanged.

Quality metrics Before After Change
Complexity 47.11 ⛔ 47.11 ⛔ 0.00
Method Length 136.35 😞 136.70 😞 0.35 👎
Working memory 1.67 ⭐ 1.67 ⭐ 0.00
Quality 25.93% 😞 25.93% 😞 0.00%
Other metrics Before After Change
Lines 761 763 2
Changed files Quality Before Quality After Quality Change
shtab/init.py 25.93% 😞 25.93% 😞 0.00%

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 ⛔ 589 ⛔ 1.22% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
shtab/init.py complete_zsh 62 ⛔ 909 ⛔ 2.38% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
shtab/init.py complete_tcsh 53 ⛔ 470 ⛔ 4.99% ⛔ 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:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

sourcery-ai[bot] avatar Sep 09 '22 13:09 sourcery-ai[bot]