-
Notifications
You must be signed in to change notification settings - Fork 8
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 #243 from bobleesj/entry-pt-create-update
feat: allow running commands with `package create` and `package update` with an entry point of `package` to `app.py`
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**Added:** | ||
|
||
* Add `package create` and `package update` commands once `scikit-package` is installed. | ||
|
||
**Changed:** | ||
|
||
* <news item> | ||
|
||
**Deprecated:** | ||
|
||
* <news item> | ||
|
||
**Removed:** | ||
|
||
* <news item> | ||
|
||
**Fixed:** | ||
|
||
* <news item> | ||
|
||
**Security:** | ||
|
||
* <news item> |
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 @@ | ||
cookiecutter |
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 @@ | ||
cookiecutter |
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,58 @@ | ||
import subprocess | ||
from argparse import ArgumentParser | ||
|
||
|
||
def create(): | ||
run_cookiecutter() | ||
|
||
|
||
def update(): | ||
# FIXME: Implement the update command. | ||
# As of now it does the same as the create command. | ||
run_cookiecutter() | ||
|
||
|
||
def run_cookiecutter(): | ||
try: | ||
subprocess.run( | ||
[ | ||
"cookiecutter", | ||
"https://github.com/Billingegroup/scikit-package", | ||
], | ||
check=True, | ||
) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Failed to run scikit-package for the following reason: {e}") | ||
|
||
|
||
def setup_subparsers(parser): | ||
# Create "create" subparser | ||
parser_create = parser.add_parser("create", help="Create a new package") | ||
parser_create.set_defaults(func=create) | ||
# Create "update" subparser | ||
parser_update = parser.add_parser( | ||
"update", help="Update an existing package" | ||
) | ||
parser_update.set_defaults(func=update) | ||
|
||
|
||
def main(): | ||
"""Entry point for the scikit-package CLI. | ||
Examples | ||
-------- | ||
>>> package create | ||
>>> package update | ||
""" | ||
|
||
parser = ArgumentParser( | ||
description="Manage package operations with scikit-package." | ||
) | ||
subparsers = parser.add_subparsers(dest="command", required=True) | ||
setup_subparsers(subparsers) | ||
args = parser.parse_args() | ||
args.func() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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