-
Notifications
You must be signed in to change notification settings - Fork 100
feat(shiny create): Support simpler syntax for --github
flag
#1623
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This works but doesn't handle when `template=None`
shiny/_main.py
Outdated
@@ -602,22 +605,18 @@ def create( | |||
template: Optional[str] = None, | |||
mode: Optional[str] = None, | |||
github: Optional[str] = None, | |||
dir: Optional[str | Path] = None, | |||
dir: Optional[Path] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this is always a Path
? If so, why keep the str
runtime check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I didn't mean to remove str
from the input typing. I do think we could use
type=click.Path(dir_okay=True, file_okay=False)
for the --dir
option. This does guarantee that dir
is then a Path()
. I'd still be on the fence about allowing str
, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, yea, that seems sensible, and I don't see any harm in keeping the str
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept it but while looking at this realized we:
- Should be asking for the destination directory earlier, e.g. before asking whether they want express/core syntax
- Can better throw an error if the
--dir
is actually a file - Can improve the
directory_prompt()
experience by makingdest_dir
the first argument.
… make `dest_dir` more prominent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once tests are passing
* main: refactor: `shiny create` and `shiny add test` supporting functions (#1629) Update CHANGELOG.md Fix #1601: Force text/javascript for .js files Work around griffe 1.0 breaking changes feat(shiny create): Support simpler syntax for `--github` flag (#1623) Make sure `Chat.messages(format='google')` converts role assistant -> model (#1622) Fix `NormalizerRegistry.register()` (#1619) Update JS/CSS from shiny and bslib (#1617) Add ability to update `Chat()`'s input placeholder (#1594) docs: Add double-quotes to shiny[theme] (#1605) `json.dump()` each websocket message once instead of twice (#1597)
* main: setup.cfg -> pyproject.toml (posit-dev#1625) docs(navset): Add server function to navset docs (posit-dev#1596) Pin syrupy to avoid pytest-rerunfailures incompatibility (posit-dev#1632) refactor: `shiny create` and `shiny add test` supporting functions (posit-dev#1629) Update CHANGELOG.md Fix posit-dev#1601: Force text/javascript for .js files Work around griffe 1.0 breaking changes feat(shiny create): Support simpler syntax for `--github` flag (posit-dev#1623) Make sure `Chat.messages(format='google')` converts role assistant -> model (posit-dev#1622) Fix `NormalizerRegistry.register()` (posit-dev#1619) Update JS/CSS from shiny and bslib (posit-dev#1617) Add ability to update `Chat()`'s input placeholder (posit-dev#1594) docs: Add double-quotes to shiny[theme] (posit-dev#1605) `json.dump()` each websocket message once instead of twice (posit-dev#1597) docs: Update note on style keys allowing for kebab-case (posit-dev#1595) docs: fix navset function links (posit-dev#1590) Get `ui.Chat()` working inside Shiny modules (posit-dev#1582) bug(notification): Allow for duration to be `None` and passed to client (posit-dev#1577) Fix logic for detection of support files in docs (posit-dev#1580) docs(navset): Add examples for navset (posit-dev#1579)
This PR replaces the requirement for a full URL to a template hosted in a GitHub repo, replacing it with a shorter, more familiar syntax.
Because there are many common ways to specify the
ref
andpath
portions of the GitHub spec, I ended up adding support for more than a few variations{repo_owner}/{repo_name}@{ref}:{path}
{repo_owner}/{repo_name}:{path}@{ref}
{repo_owner}/{repo_name}:{path}
{repo_owner}/{repo_name}/{path}
{repo_owner}/{repo_name}/{path}@{ref}
{repo_owner}/{repo_name}/{path}?ref={ref}
Alternatively, the
--template
flag can now be combined with the--github
flag, so these iterations are now the same as the above:I'd really like to support listing available templates and asking the user to pick one, so that we could support
with a missing
--template
flag.shiny create
would downloadposit-dev/py-shiny-templates
, find the available templates in the repo, and provide a menu to users.While here, I've also improved the use of formatting and color in the CLI interface. Here's an example of the output seen when creating the
map-distance
template: