-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from KusionStack/dev/peefy/feat_add_plugin_subm…
…odule feat: add plugins submodule.
- Loading branch information
Showing
12 changed files
with
1,141 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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,5 @@ | ||
# Copyright 2021 The KCL Authors. All rights reserved. | ||
|
||
import kclvm.internal.kclvm_internal.main as main | ||
|
||
main.Main() |
This file contains 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,27 @@ | ||
# Copyright 2021 The KCL Authors. All rights reserved. | ||
|
||
import sys | ||
|
||
import kclvm.api.version as version | ||
|
||
USAGE = """\ | ||
usage: kclvm -m kclvm.api.version | ||
kclvm -m kclvm.api.version -checksum | ||
kclvm -m kclvm.api.version -h | ||
""" | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) == 2 and (sys.argv[1] == "-h" or sys.argv[1] == "-help"): | ||
print(USAGE) | ||
sys.exit(0) | ||
|
||
if len(sys.argv) == 2 and sys.argv[1] == "-checksum": | ||
print(version.CHECKSUM) | ||
sys.exit(0) | ||
|
||
if len(sys.argv) > 1: | ||
print(USAGE) | ||
sys.exit(1) | ||
|
||
print(version.VERSION) | ||
sys.exit(0) |
This file contains 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,52 @@ | ||
# Copyright 2021 The KCL Authors. All rights reserved. | ||
|
||
import sys | ||
from dataclasses import dataclass | ||
|
||
import kclvm.compiler.parser as parser | ||
import kclvm.compiler.build.compiler as compiler | ||
|
||
from .transformer import transform_ast_to_kclx_ast_json_str | ||
|
||
USAGE = """\ | ||
usage: kclvm -m kclvm.internal.kclx -f=<file> | ||
usage: kclvm -m kclvm.internal.kclx -h | ||
""" | ||
|
||
|
||
@dataclass | ||
class CmdFlags: | ||
help: bool = False | ||
file: str = "" | ||
|
||
|
||
def parse_flags(args: list) -> CmdFlags: | ||
m = CmdFlags() | ||
for s in args: | ||
if s == "-h" or s == "-help": | ||
m.help = True | ||
continue | ||
|
||
if s.startswith("-f="): | ||
value = s[len("-f=") :] | ||
m.file = value | ||
continue | ||
|
||
return m | ||
|
||
|
||
def main(): | ||
flags = parse_flags(sys.argv[1:]) | ||
|
||
if flags.help: | ||
print(USAGE) | ||
sys.exit(0) | ||
|
||
if flags.file: | ||
ast_prog = parser.LoadProgram(*flags.file.split(",")) | ||
compiler.FixAndResolveProgram(ast_prog) | ||
print(transform_ast_to_kclx_ast_json_str(ast_prog)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.