-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from vkottler/dev/2.7.0
2.7.0 - Add 'download' command
- Loading branch information
Showing
13 changed files
with
213 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
major: 2 | ||
minor: 6 | ||
minor: 7 | ||
patch: 0 | ||
entry: mbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
""" | ||
Test the 'commands.download' module. | ||
""" | ||
|
||
# built-in | ||
from tempfile import TemporaryDirectory | ||
|
||
# module under test | ||
from yambs import PKG_NAME | ||
from yambs.entry import main as yambs_main | ||
|
||
|
||
def test_download_basic(): | ||
"""Test the 'download' command.""" | ||
|
||
with TemporaryDirectory() as tmpdir: | ||
assert yambs_main([PKG_NAME, "-C", str(tmpdir), "download"]) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
An entry-point for the 'download' command. | ||
""" | ||
|
||
# built-in | ||
from argparse import ArgumentParser as _ArgumentParser | ||
from argparse import Namespace as _Namespace | ||
from pathlib import Path | ||
|
||
# third-party | ||
from vcorelib.args import CommandFunction as _CommandFunction | ||
|
||
# internal | ||
from yambs.dependency.github import GithubDependency, default_filt | ||
|
||
|
||
def download_cmd(args: _Namespace) -> int: | ||
"""Execute the download command.""" | ||
|
||
dep = GithubDependency(args.owner, args.repo) | ||
|
||
# Download and extract things. | ||
dep.download_release_assets( | ||
default_filt(args.output, pattern=args.pattern) | ||
) | ||
|
||
return 0 | ||
|
||
|
||
def add_download_cmd(parser: _ArgumentParser) -> _CommandFunction: | ||
"""Add download-command arguments to its parser.""" | ||
|
||
parser.add_argument( | ||
"-o", | ||
"--owner", | ||
default="vkottler", | ||
help="repository owner (default: '%(default)s')", | ||
) | ||
parser.add_argument( | ||
"-r", | ||
"--repo", | ||
default="toolchains", | ||
help="repository name (default: '%(default)s')", | ||
) | ||
parser.add_argument( | ||
"-O", | ||
"--output", | ||
type=Path, | ||
default=Path("toolchains"), | ||
help="output directory (default: '%(default)s')", | ||
) | ||
parser.add_argument( | ||
"-p", | ||
"--pattern", | ||
default=".*", | ||
help=( | ||
"a pattern to use to select project " | ||
"specifications filtered by name" | ||
), | ||
) | ||
|
||
return download_cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters