Skip to content
Merged
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion scripts/set-alias-page.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Stage modified pages (requires 'git' on $PATH and TLDR_ROOT to be a Git repository).
-n, --dry-run
Show what changes would be made without actually modifying the page.
-i, --inexact
Ignore direct template matching to find non-standard alias pages.

Examples:
1. Create a new alias page interactively:
Expand Down Expand Up @@ -80,6 +82,7 @@ class Config:
templates: dict[str, str]
dry_run: bool = False
language: str = ""
inexact: bool = False


@dataclass
Expand Down Expand Up @@ -269,7 +272,7 @@ def get_alias_command_in_page(path: Path, alias_pattern: str) -> AliasPageConten
if len(command_lines) != 2 or not title:
return AliasPageContent(title="", original_command="", documentation_command="")

if alias_pattern == get_locale_alias_pattern("en"):
if not config.inexact and alias_pattern == get_locale_alias_pattern("en"):
stripped_template = config.templates["en"]
stripped_template = stripped_template.replace("example", "")

Expand Down Expand Up @@ -468,6 +471,14 @@ def main():
parser = create_argument_parser(
"Sets the alias page for all translations of a page"
)
parser.add_argument(
"-i",
"--inexact",
action="store_true",
default=False,
help="Do not match precisely with the alias template",
)

args = parser.parse_args()

# Print usage information if no arguments were provided
Expand All @@ -486,6 +497,7 @@ def main():
templates=templates,
dry_run=args.dry_run,
language=args.language,
inexact=args.inexact,
)

target_paths = []
Expand Down
Loading