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

Proposal: Fix for multilines and composite scripts listing #1151

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

noirbizarre
Copy link
Member

@noirbizarre noirbizarre commented Jun 22, 2022

Pull Request Check List

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

While the current script listing is working fine when your command are short one-liners, it was broken for multilines scripts on main (where this PR was initially implemented).
Now that dev switched on a rich table display, I'm not sure whether it is improvement or not so I submit it anyway,

This PR improvement proposal was to merge the Script and Description column into a single Description column displaying the help if available and if not:

  • display the sequence of calls for composite
  • display the first line of script with a ellipsis if it has been truncated

Also, the list is now sorted.

Example

Here the same output for main, dev and this PR for this given tool.pdm.scripts:

[tool.pdm.scripts]
all = {composite = ["format", "lint", "cover"]}
test = "pytest better/ tests/"
format = { shell = """\
isort better/
black better/
""" }
doc = "sphinx-build docs docs/_build/html"
"doc:watch" = "sphinx-autobuild docs docs/_build/html"

[tool.pdm.scripts.lint]
shell = """\
  echo "Flakes"
  flake8 better
  echo "isort"
  isort --check better
  echo "black"
  black --check better
  echo "MyPy"
  mypy better
"""

[tool.pdm.scripts.cover]
help = "Run tests with coverage"
cmd = """
pytest
  --cov-report=term
  --cov=better
  --cov-report=html:reports/coverage
  --cov-report=xml:reports/coverage.xml
  --junitxml=reports/tests.xml
"""

Main

Capture d’écran du 2022-06-22 13-21-27

Note: the composite task has been removed to be able to run the command

Dev

Capture d’écran du 2022-06-22 13-22-03

Proposal

Capture d’écran du 2022-06-22 13-22-53

@noirbizarre noirbizarre force-pushed the fix/multiline-script-listing branch 2 times, most recently from 70a5bac to 908a2e4 Compare June 22, 2022 11:38
@frostming
Copy link
Collaborator

The ⮨ ellipsis doesn't look good on my machine(M1 Mac with WezTerm, Rec Mono). It doesn't even render on Chrome.

Better to choose another character.

@noirbizarre
Copy link
Member Author

Ok then let's change that. It was ⮨, here a list of alternatives (so you can test it and validate it is working before i update the PR) I see:

  1. The classical ellipsis:
  2. Same arrow but thinner:
  3. Same but a bit curvier:
  4. The fat one:

Or if you have any other suggestion or preference.
I can render the porposal with each to choose if you want.

@frostming
Copy link
Collaborator

frostming commented Jun 22, 2022

I prefer the classical ellipsis and fallback to three dots ... on Windows cmd. 😞

I have to say this is a great UI improvement, well done @noirbizarre

@noirbizarre noirbizarre force-pushed the fix/multiline-script-listing branch from 908a2e4 to d54bd6d Compare June 22, 2022 16:26
@noirbizarre
Copy link
Member Author

noirbizarre commented Jun 22, 2022

Updated with a classical ellipsis and a fallback on 3 dots for legacy windows terminals.

@frostming it's why I love open-source: you find an awesome tool, open source gives you the opportunity to make more awesome to you by contributing. Given I'm a full time developer, and Python packaging have been so painful those last year, I'm glad PDM exists solving my main Python irritation point and I even more glad to contribute to make it more awesome !!! (And BTW, I apologize in advance because I know I will be flooding this repository with pull requests for some time)

@frostming
Copy link
Collaborator

(And BTW, I apologize in advance because I know I will be flooding this repository with pull requests for some time)

Oh great, what big would you like to propose? BTW, would you like an alpha release or are you using the dev version already?

@noirbizarre noirbizarre force-pushed the fix/multiline-script-listing branch from d54bd6d to ec041d8 Compare June 23, 2022 09:21
@noirbizarre
Copy link
Member Author

noirbizarre commented Jun 23, 2022

And it's updated 👍🏼

An alpha release would be great (I can use the dev version but I prefer a released version, easier issue tracking)

Between others, I'd like to submit PRs for:

  • yarn-like root script (in progress): make scripts available as root cmd as long as they don't conflict with an existing one (aka. the test script should be available as pdm test
  • a bit of documentation about possible usages with direnv, writing plugins...
  • some plugins idea:
    • pdm-create: bootstrap projects using templates (like cookie-cutter or copier but builtin, same as yarn create, should bring more value than a simple pdm new = mkdir + cd + pdm init
    • pdm-releaser: like go-releaser but for and based on pdm
    • pdm-vscode: create/update vscode workspace/directory settings automatically
    • pdm-watch: define some glob pattern to watch and the scripts to run on change in your pyproject.toml (basically format,
      lint and test on change)
  • and contribute on the remaining tasks on the path to 2.0 (edtiables management, XDG dirs...)

I don't know in which order and when, yarn-like root scripts is already started so it might be the next one but after that I think I will help for the 2.0 critical path, plugins can wait

@frostming
Copy link
Collaborator

and contribute on the remaining tasks on the path to 2.0 (editables management, XDG dirs...)

I've updated the meta issue #743 about the remaining tasks, FYI edtiable management has been finished.

@noirbizarre
Copy link
Member Author

OK, I'll do the XDG/standard dirs as soon as I fnished with Yarn-like root scripts then

@codecov-commenter
Copy link

Codecov Report

Merging #1151 (ec041d8) into dev (aa8e650) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1151      +/-   ##
==========================================
+ Coverage   84.44%   84.49%   +0.05%     
==========================================
  Files          80       80              
  Lines        7089     7100      +11     
  Branches     1684     1687       +3     
==========================================
+ Hits         5986     5999      +13     
+ Misses        736      735       -1     
+ Partials      367      366       -1     
Flag Coverage Δ
unittests 84.26% <100.00%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
pdm/cli/commands/run.py 91.17% <100.00%> (+0.31%) ⬆️
pdm/termui.py 89.23% <100.00%> (+0.34%) ⬆️
pdm/cli/actions.py 79.55% <0.00%> (+0.49%) ⬆️

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 aa8e650...ec041d8. Read the comment docs.

@frostming frostming merged commit 4fd861d into pdm-project:dev Jun 23, 2022
@noirbizarre noirbizarre deleted the fix/multiline-script-listing branch June 23, 2022 10:12
frostming added a commit that referenced this pull request Jun 28, 2022
* feat(core): Use tomllib on Python 3.11 (#1072)

* docs: 📝 Fix typo in `pip install pdm` description (#1061)

* Use tomllib on Python 3.11

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* use a compatibility module

* missed one import

Co-authored-by: t106362512 <33215526+t106362512@users.noreply.github.com>
Co-authored-by: hauntsaninja <>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat(core): Replace halo, click, and termcolor with rich (#1091)

* feat(core): Use `unearth` as the backend to find and download packages (#1096)

* perf(resolver): Speed up the resolution with lazy find_matches (#1098)

* Improve the output of installing packages

* Use confirm instead of ask

* feat(core): New command: pdm publish (#1107)

* Use rich handler for logging to stderr

* feat(scripts): added composite tasks support (#1117)

* feat(core): Add option to skip hooks (#1127)

* fix(scripts): allow pdm test command to receive path arguments

* feat(hooks): added a `--skip` option to skipp scripts and hooks (#1127)

fix #948

* feat(hooks): use PDM_SKIP_HOOKS environement variable as fallback for skip list

* feat(core): Support setup.py import (#1137)

* Update completion script

* fix(resolution): fix a bug that versions with local part can't be found and installed
Close #1093

* feat(core): forbid editable depenencies in project table (#1140)

* Make the error message more friendly

* doc: improve the docs about dependencies

* doc: add CLI reference doc

* doc: use asciiart as the program description

* chore: remove remaining artifacts from #1127 (#1152)

* Feature: complete lifecycle signals and documentation (#1147)

* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks

* feat: Update pdm-pep517 to 1.0 (#1153)

* fix(scripts): merge the Script and Description field from listing (#1151)

* feat: fetch the candidate hashes concurrently (#1154)

* feat: fetch the candidate hashes concurrently

* add news

* Feat/respect-source-order (#1155)

* doc: restructure the docs about project metadata and build configuration

* parse pep 621 metadata to avoid build (#1156)

* feat: Remove the compatible support for pdm legacy metadata (#1157)

* fix(config): use platform standard directories for all PDM directories (#1161)

Fixes #1150

* fix(#1156): only trust parsing result when all are static

* New build configuration table

* chore: added a tox.ini file for easier local testing against all Python versions (#1160)

* feat(CLI): Yarn-like root scripts fallback (#1159)

* feat(hooks): added a post_use hook (#1163)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: t106362512 <33215526+t106362512@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel H <noirbizarre@users.noreply.github.com>
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.

3 participants