Skip to content

Commit

Permalink
Checkout repo
Browse files Browse the repository at this point in the history
  • Loading branch information
grant0417 committed May 29, 2024
1 parent 7ebfeec commit 0267f03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
build-completion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rye
run: curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
- run: echo "$HOME/.rye/shims" >> $GITHUB_PATH
Expand Down
20 changes: 10 additions & 10 deletions src/aws_cli_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import re
import os
from os.path import dirname, realpath
from pathlib import Path
from awscli.customizations.commands import BasicCommand
from awscli.clidriver import ServiceCommand, ServiceOperation

exportDirectory = dirname(dirname(dirname(realpath(__file__))))
exportDirectory = Path("export")
exportTypescript = True


Expand Down Expand Up @@ -174,14 +174,14 @@ def saveJsonAsSpec(d, path):
else "var completionSpec ="
)
extension = ".ts" if exportTypescript else ".js"
directory = "{}/export/{}/".format(
exportDirectory, "ts" if exportTypescript else "js"

file_path = exportDirectory.joinpath("ts" if exportTypescript else "js").joinpath(
f"{path}{extension}"
)
final = "{} {}".format(prefix, json.dumps(d, indent=4))
file_path.parent.mkdir(parents=True, exist_ok=True)

f = open(directory + path + extension, "w")
f.write(final)
f.close()
final = f"{prefix} {json.dumps(d, indent=4)}"
file_path.write_text(final)


root = {"name": "aws", "subcommands": []}
Expand All @@ -200,7 +200,7 @@ def read_commands(command_table, session, **kwargs):
print("ServiceCommand:", command_name)

spec = generateCompletionSpecSkeleton(command_name, command)
path = "aws/{}".format(spec["name"])
path = f"aws/{spec["name"]}"
saveJsonAsSpec(spec, path)

root["subcommands"].append(
Expand All @@ -215,7 +215,7 @@ def read_commands(command_table, session, **kwargs):
print("ServiceOperation:", command._parent_name, command_name)
elif isinstance(command, BasicCommand):
spec = parseBasicCommand(command)
path = "aws/{}".format(spec["name"])
path = f"aws/{spec["name"]}"
# save spec file to disk
saveJsonAsSpec(spec, path)

Expand Down

0 comments on commit 0267f03

Please sign in to comment.