Skip to content

[tools/shoestring]: Shortened command and subcommand autocompletion #1439

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

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

ccHarvestasya
Copy link
Contributor

Problem

  • Running the tool requires prefixing with python3 -m
  • No autocomplete support for subcommands

Solution

  • Define Poetry scripts to eliminate the need for python3 -m
  • Enable subcommand autocompletion using argcomplete

This is not something I use frequently, but it’s a nice-to-have improvement.

Copy link

codecov bot commented Jun 21, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 99.21%. Comparing base (c028861) to head (dfe6e29).

Files with missing lines Patch % Lines
tools/shoestring/shoestring/__main__.py 80.00% 1 Missing ⚠️
tools/shoestring/shoestring/wizard/__main__.py 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1439      +/-   ##
==========================================
+ Coverage   98.28%   99.21%   +0.93%     
==========================================
  Files         164      159       -5     
  Lines        6770     6642     -128     
  Branches      143      143              
==========================================
- Hits         6654     6590      -64     
+ Misses        116       52      -64     
Flag Coverage Δ
explorer-rest ?
tools-shoestring 99.37% <75.00%> (+2.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tools/shoestring/shoestring/__main__.py 97.82% <80.00%> (+0.20%) ⬆️
tools/shoestring/shoestring/wizard/__main__.py 91.52% <66.66%> (+91.52%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -23,5 +23,9 @@ classifiers = [

include = ['shoestring/lang/*/LC_MESSAGES/messages.mo']

[tool.poetry.scripts]
shoestring = "shoestring.__main__:entry_point"
shoestring-wizard = "shoestring.wizard.__main__:entry_point"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add tests for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible to run tests that go through each entry point, so I’ve added them.
However, these are just tests that pass through the entry points.
Do you think it would be better to include some assertions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. Those tests are fine.
Initially, I was thinking of installing a Shoestring(pip install -e .) to verify that the shoestring command runs.

@@ -1,4 +1,5 @@
aiohttp~=3.12.6
argcomplete~=3.6.2
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to only work with a specific shell? 🤔
You’re using bash or zsh as your shell

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. It needs to be executable simply as shoestring.
    (This has already been addressed via tool.poetry.scripts.)

  2. To enable autocompletion, you need to run eval "$(register-python-argcomplete shoestring)" (or add it to your .bashrc to enable it permanently).

Since an extra command is required, it ends up feeling like a hidden feature 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Yes, but I was wondering if argcomplete only supports bash or zsh shell

  2. Yes, will need to update the README on how to enable autocompletion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. It looks like argcomplete only supports Bash and Zsh.
    Are there any other shells we should consider supporting? For example, PowerShell?
    If you have suggestions for other shells worth supporting, let me know — I’ll look into whether we can support them.

  2. I'll add instructions for enabling autocomplete to the README later.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Adding the list of supported shells to the README is sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll add it to the README later.

@ccHarvestasya ccHarvestasya force-pushed the shoestring/add_entrypoints_to_poetry branch from b0cde07 to dfe6e29 Compare July 1, 2025 12:52
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.

2 participants