mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
flake-modules/new-plugin: optionalize package name
New default behavior accepts just the upstream plugin name and performs the same package name normalization from nixpkgs.
This commit is contained in:
parent
c3b04f76ec
commit
94298096e8
1 changed files with 23 additions and 2 deletions
|
@ -39,6 +39,19 @@ test_nix_template = """{{
|
|||
"""
|
||||
|
||||
|
||||
def normalized_name(name) -> str:
|
||||
"""
|
||||
Convert name to a normalized package name format.
|
||||
|
||||
Args:
|
||||
name (str): The original name to normalize.
|
||||
|
||||
Returns:
|
||||
str: The normalized package name.
|
||||
"""
|
||||
return name.replace(".", "-")
|
||||
|
||||
|
||||
def kebab_case(input_string):
|
||||
"""
|
||||
Convert a string to kebab-case.
|
||||
|
@ -122,12 +135,20 @@ def main():
|
|||
parser.add_argument(
|
||||
"originalName", type=str, help="Original name of the new plugin"
|
||||
)
|
||||
parser.add_argument("package", type=str, help="Package name of the new plugin")
|
||||
parser.add_argument(
|
||||
"--package",
|
||||
"-p",
|
||||
type=str,
|
||||
help="Package name of the new plugin (defaults to normalized version of originalName)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Calculate name
|
||||
name = kebab_case(args.originalName)
|
||||
|
||||
# Use provided package name or default to normalized original name
|
||||
package = args.package if args.package else normalized_name(args.originalName)
|
||||
|
||||
# Define paths
|
||||
root_identifier = "flake.nix"
|
||||
root_dir = find_project_root(root_identifier)
|
||||
|
@ -141,7 +162,7 @@ def main():
|
|||
default_nix_template,
|
||||
name,
|
||||
args.originalName,
|
||||
args.package,
|
||||
package,
|
||||
)
|
||||
create_test_file(
|
||||
test_path,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue