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

feat(shiny create): Support simpler syntax for --github flag #1623

Merged
merged 24 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5da8ddb
feat(shiny create): Support simpler syntax for `--github` flag
gadenbuie Aug 20, 2024
70582a7
chore: fix linting issues
gadenbuie Aug 21, 2024
c2c2cbf
chore: rename `path_rel_wd()`
gadenbuie Aug 21, 2024
a28f341
chore: don't eagerly delete repo.zip
gadenbuie Aug 21, 2024
2c0a70d
chore: style
gadenbuie Aug 21, 2024
a0057b4
chore: pass `template` into `use_git_template()`
gadenbuie Aug 21, 2024
46df38a
Merged origin/main into feat/create-improve-gh-spec
gadenbuie Aug 21, 2024
a69bd21
feat: use rich CLI with colors and formatting
gadenbuie Aug 21, 2024
ad502c4
chore: Update help text for `--github` flag
gadenbuie Aug 21, 2024
005716f
feat: Make it easier to install into current directory
gadenbuie Aug 21, 2024
f7e1880
chore: Add fixme comment
gadenbuie Aug 21, 2024
722dd3b
feat: echo github spec and template being used
gadenbuie Aug 21, 2024
74e5ea0
docs: Add changelog
gadenbuie Aug 21, 2024
d5512b8
fix quotes in f string
gadenbuie Aug 21, 2024
99797cf
chore: review feedback
gadenbuie Aug 21, 2024
41837ca
chore: Rename input `github` arg to `use_git_template()`
gadenbuie Aug 21, 2024
632ad01
chore: Rename `use_template_github()`
gadenbuie Aug 21, 2024
7c7242d
chore: rename `use_template_internal()`
gadenbuie Aug 21, 2024
95452f3
chore: Add comment about overall github spec parsing approach
gadenbuie Aug 21, 2024
67c4b74
chore: rename input to `github_zip_url()`
gadenbuie Aug 21, 2024
29a896f
chore: reuse `spec_cli`
gadenbuie Aug 21, 2024
eee4f3e
feat: Show download zip errors if github fails
gadenbuie Aug 21, 2024
9ea53a9
chore: simplify error printing
gadenbuie Aug 21, 2024
064f59f
chore: `directory_prompt()` improve not a file check, prompt earlier,…
gadenbuie Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `ui.Chat()` gains a new `.update_user_input()` method, which adds the ability to update the input placeholder message. As a result, `.set_user_message()` is now deprecated (since the new method can also be used to update the message). (#1594)

* `shiny create` now supports a succinct format for specifying the GitHub repository via the `--github` flag, e.g. `--github posit-dev/py-shiny-templates`. You can now also use `--github` and `--template` together, in which case `--github` should point to a repository containing a directory matching the name provided in `--template`. (#1623)

### Other changes

### Bug fixes
Expand Down
30 changes: 16 additions & 14 deletions shiny/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,7 @@ def test(
@click.option(
"--template",
"-t",
type=click.Choice(
list({**app_template_choices, **package_template_choices}.values()),
case_sensitive=False,
),
type=click.STRING,
help="Choose a template for your new application.",
)
@click.option(
Expand All @@ -584,11 +581,18 @@ def test(
@click.option(
"--github",
"-g",
help="The GitHub URL of the template sub-directory. For example https://github.com/posit-dev/py-shiny-templates/tree/main/dashboard",
help="""
The GitHub repo containing the template, e.g. 'posit-dev/py-shiny-templates'.
Can be in the format '{repo_owner}/{repo_name}', '{repo_owner}/{repo_name}@{ref}',
or '{repo_owner}/{repo_name}:{path}@{ref}'.
Alternatively, a GitHub URL of the template sub-directory, e.g
'https://github.com/posit-dev/py-shiny-templates/tree/main/dashboard'.
""",
)
@click.option(
"--dir",
"-d",
type=str,
help="The destination directory, you will be prompted if this is not provided.",
)
@click.option(
Expand All @@ -602,22 +606,20 @@ def create(
template: Optional[str] = None,
mode: Optional[str] = None,
github: Optional[str] = None,
dir: Optional[str | Path] = None,
dir: Optional[Path | str] = None,
package_name: Optional[str] = None,
) -> None:
from ._template_utils import template_query, use_git_template
from ._template_utils import use_template_github, use_template_internal

if github is not None and template is not None:
raise click.UsageError("You cannot provide both --github and --template")
print(f"dir is {dir}")

if isinstance(dir, str):
if dir is not None:
dir = Path(dir)

if github is not None:
use_git_template(github, mode, dir)
return

template_query(template, mode, dir, package_name)
use_template_github(github, template=template, mode=mode, dest_dir=dir)
else:
use_template_internal(template, mode, dir, package_name)


@main.command(
Expand Down
Loading
Loading