Skip to content

Commit 4731037

Browse files
committed
bump version, merge pull request #43 from iterative/preamble
2 parents b3f8d79 + 2a2dadd commit 4731037

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Test
22
on: [push, pull_request]
33
jobs:
44
check:
5-
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
5+
if: startsWith(github.ref, 'refs/tags') || github.event_name == 'pull_request' || github.repository_owner != 'iterative'
66
name: Check
77
runs-on: ubuntu-latest
88
steps:
@@ -24,7 +24,7 @@ jobs:
2424
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2525
- run: pre-commit run -a --show-diff-on-failure
2626
test:
27-
if: github.event_name != 'pull_request' || github.head_ref != 'devel'
27+
if: startsWith(github.ref, 'refs/tags') || github.event_name == 'pull_request' || github.repository_owner != 'iterative'
2828
name: Test py${{ matrix.python }}
2929
runs-on: ubuntu-latest
3030
strategy:
@@ -55,15 +55,19 @@ jobs:
5555
requirements: twine setuptools wheel setuptools_scm[toml]
5656
build: true
5757
password: ${{ secrets.PYPI_TOKEN }}
58-
upload: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
58+
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
5959
- name: Changelog
6060
run: git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD > _CHANGES.md
61-
- if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
61+
- id: meta
62+
name: Metadata
63+
run: |
64+
echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
65+
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
6266
uses: softprops/action-gh-release@v1
6367
env:
6468
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
6569
with:
66-
name: shtab ${{ github.ref }} beta
70+
name: shtab ${{ steps.meta.outputs.tag }} beta
6771
body_path: _CHANGES.md
6872
draft: true
6973
files: |

examples/customcomplete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def get_main_parser():
4040
subparsers.dest = "subcommand"
4141

4242
parser = subparsers.add_parser("completion")
43-
shtab.add_argument_to(parser, "shell", parent=main_parser) # magic!
43+
shtab.add_argument_to(
44+
parser, "shell", parent=main_parser, preamble=PREAMBLE
45+
) # magic!
4446

4547
parser = subparsers.add_parser("process")
4648
# `*.txt` file tab completion

shtab/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,10 @@ def complete(
575575
)
576576

577577

578-
def completion_action(parent=None):
578+
def completion_action(parent=None, preamble=""):
579579
class PrintCompletionAction(Action):
580580
def __call__(self, parser, namespace, values, option_string=None):
581-
print(complete(parent or parser, values))
581+
print(complete(parent or parser, values, preamble=preamble))
582582
parser.exit(0)
583583

584584
return PrintCompletionAction
@@ -589,6 +589,7 @@ def add_argument_to(
589589
option_string="--print-completion",
590590
help="print shell completion script",
591591
parent=None,
592+
preamble="",
592593
):
593594
"""
594595
parser : argparse.ArgumentParser
@@ -605,7 +606,7 @@ def add_argument_to(
605606
"choices": SUPPORTED_SHELLS,
606607
"default": None,
607608
"help": help,
608-
"action": completion_action(parent),
609+
"action": completion_action(parent, preamble),
609610
}
610611
if option_string[0][0] != "-": # subparser mode
611612
kwargs.update(default=SUPPORTED_SHELLS[0], nargs="?")

0 commit comments

Comments
 (0)