-
Notifications
You must be signed in to change notification settings - Fork 0
WIP on unit names #136
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
Draft
mitch10593
wants to merge
1
commit into
main
Choose a base branch
from
feature/135-add-units-names-full-text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
WIP on unit names #136
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """CLI entry point for Foothold Sitac. | ||
|
|
||
| Usage:: | ||
|
|
||
| foothold-sitac serve | ||
| foothold-sitac extract-unit-names --dcs-path "C:\\..." | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
| from typing import Annotated, Optional | ||
|
|
||
| import typer | ||
| import uvicorn | ||
|
|
||
| from foothold_sitac.config import get_config | ||
|
|
||
| app = typer.Typer(name="foothold-sitac", help="Foothold Sitac — tactical map server for DCS World") | ||
|
|
||
|
|
||
| @app.command() | ||
| def serve() -> None: | ||
| """Start the Foothold Sitac web server.""" | ||
| config = get_config() | ||
| uvicorn.run( | ||
| "foothold_sitac.main:app", | ||
| host=config.web.host, | ||
| port=config.web.port, | ||
| reload=config.web.reload, | ||
| ) | ||
|
|
||
|
|
||
| @app.command() | ||
| def extract_unit_names( | ||
| dcs_path: Annotated[ | ||
| Optional[str], | ||
| typer.Option(help="Path to DCS World installation (reads dcs.install_path from config if not set)"), | ||
| ] = None, | ||
| output: Annotated[ | ||
| Optional[Path], | ||
| typer.Option(help="Output JSON file path"), | ||
| ] = None, | ||
| ) -> None: | ||
| """Extract unit type DisplayNames from a DCS World installation.""" | ||
| from foothold_sitac.unit_names import UNIT_NAMES_PATH, extract_all, save_unit_display_names | ||
|
|
||
| resolved_path = dcs_path or get_config().dcs.install_path | ||
| if not resolved_path: | ||
| typer.echo("Error: No DCS path provided. Use --dcs-path or set dcs.install_path in config.yml", err=True) | ||
| raise typer.Exit(code=1) | ||
|
|
||
| dcs = Path(resolved_path) | ||
| if not dcs.exists(): | ||
| typer.echo(f"Error: DCS path does not exist: {dcs}", err=True) | ||
| raise typer.Exit(code=1) | ||
|
|
||
| typer.echo(f"Extracting unit names from: {dcs}") | ||
| mappings = extract_all(dcs) | ||
|
|
||
| if not mappings: | ||
| typer.echo("Warning: No unit mappings found. Check the DCS path.", err=True) | ||
| raise typer.Exit(code=1) | ||
|
|
||
| out = output or UNIT_NAMES_PATH | ||
| save_unit_display_names(mappings, out) | ||
| typer.echo(f"Written {len(mappings)} unit display names to {out}") |
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
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
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.
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.
suggestion (performance): Full unit-name extraction on every startup may be very slow for large DCS installs.
Calling
refresh_unit_display_nameson every startup will repeatedly scan a large portion of the DCS install tree (potentially thousands of Lua files), which can noticeably slow startup or cause timeouts in constrained environments. Consider limiting this to cases where the JSON file is missing, making it configurable, or moving the heavy extraction to an explicit CLI-only command while startup only loads the existing JSON file.