-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JSON interface for Lean code (#160)
Co-authored-by: Andrew Wells <[email protected]> Co-authored-by: Bhakti Shah <[email protected]>
- Loading branch information
1 parent
e1d10d7
commit 4a87db3
Showing
29 changed files
with
15,203 additions
and
28 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
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
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
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,47 @@ | ||
/- | ||
Copyright 2022-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-/ | ||
|
||
import Lean.Data.Json.FromToJson | ||
|
||
import DiffTest.Main | ||
import DiffTest.Parser | ||
|
||
/-! This file provides a basic command line interface for authorization | ||
and validation. It uses the interface functions defined in `Difftest`. -/ | ||
|
||
open DiffTest | ||
|
||
def readFile (filename : String) : IO String := | ||
IO.FS.readFile filename | ||
|
||
def printUsage (err : String) : IO Unit := | ||
IO.println s!"{err}\nUsage: Cli <command> <file>" | ||
|
||
def main (args : List String) : IO Unit := | ||
match args.length with | ||
| 2 => do | ||
let command := args.get! 0 | ||
let filename := args.get! 1 | ||
let request ← readFile filename | ||
match command with | ||
| "authorize" => | ||
let response := isAuthorizedDRT request | ||
IO.println response | ||
| "validate" => | ||
let response := validateDRT request | ||
IO.println response | ||
| _ => printUsage s!"Invalid command `{command}` (expected `authorize` or `validate`)" | ||
| n => printUsage s!"Incorrect number of arguments (expected 2, but got {n})" |
Oops, something went wrong.