Repository navigation
fix: Explain how with-connect works in --help and reject invalid --port #63
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -22,6 +22,34 @@ | |
| REGISTRY_CUTOVER_YEAR = 2026 | ||
| REGISTRY_CUTOVER_MONTH = 4 | ||
|
|
||
| DESCRIPTION = """\ | ||
| Starts Posit Connect in Docker and waits until it is ready. | ||
|
|
||
| With no command, prints CONNECT_API_KEY, CONNECT_SERVER and CONTAINER_ID | ||
| as KEY=value lines on stdout and leaves the container running. | ||
| Stop it later with: with-connect --stop CONTAINER_ID | ||
| Progress and errors go to stderr. | ||
|
|
||
| With "-- COMMAND", runs COMMAND with CONNECT_API_KEY and CONNECT_SERVER | ||
| set, then stops the container and exits with the command's exit code.""" | ||
|
cgraham-rs marked this conversation as resolved.
|
||
|
|
||
| EPILOG = """\ | ||
| examples: | ||
| with-connect --license ./rstudio-connect.lic | ||
| with-connect --license ./rstudio-connect.lic -- bash -c 'curl -H "Authorization: Key $CONNECT_API_KEY" $CONNECT_SERVER/__api__/v1/content' | ||
| """ | ||
|
|
||
|
|
||
| def port_number(value: str) -> int: | ||
| """Parse --port. Docker can only map a fixed host port from 1 to 65535.""" | ||
| try: | ||
| port = int(value) | ||
| except ValueError: | ||
| raise argparse.ArgumentTypeError(f"invalid port value: '{value}'") | ||
| if not 1 <= port <= 65535: | ||
| raise argparse.ArgumentTypeError(f"{port} is not a valid port. Use a free port from 1 to 65535.") | ||
| return port | ||
|
Comment on lines
+43
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 |
||
|
|
||
|
|
||
| def parse_args(): | ||
| """ | ||
|
|
@@ -31,7 +59,9 @@ def parse_args(): | |
| and the command to run against Connect. | ||
| """ | ||
| parser = argparse.ArgumentParser( | ||
| description="Run Posit Connect with optional command execution" | ||
| description=DESCRIPTION, | ||
| epilog=EPILOG, | ||
| formatter_class=argparse.RawDescriptionHelpFormatter, | ||
| ) | ||
| parser.add_argument( | ||
| "--version", | ||
|
|
@@ -45,7 +75,7 @@ def parse_args(): | |
| ) | ||
| parser.add_argument( | ||
| "--image", | ||
| help="Container image to use, including tag (overrides --version)", | ||
| help="Container image to use, including tag (use instead of --version)", | ||
| ) | ||
| parser.add_argument( | ||
| "--config", help="Path to rstudio-connect.gcfg configuration file" | ||
|
|
@@ -64,7 +94,7 @@ def parse_args(): | |
| ) | ||
| parser.add_argument( | ||
| "--port", | ||
| type=int, | ||
| type=port_number, | ||
| default=3939, | ||
| help="Port to map the Connect container to (default: 3939)", | ||
| ) | ||
|
|
@@ -74,7 +104,7 @@ def parse_args(): | |
| default=None, | ||
| const="", # sentinel for --stop without argument | ||
| metavar="CONTAINER_ID", | ||
| help="Stop a running Connect container by ID (uses CONTAINER_ID env var if not specified)", | ||
| help="Stop a running Connect container by ID (uses the exported CONTAINER_ID env var if not specified)", | ||
| ) | ||
|
|
||
| # Handle -- separator and capture remaining args | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.