Skip to content

Commit

Permalink
feat: Enum of strings for compilation mode over many disjoint boole…
Browse files Browse the repository at this point in the history
…an flags
  • Loading branch information
novusnota committed May 1, 2024
1 parent 93c7fe0 commit 0b18c8c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The `try` and `try-catch` statements: PR [#212](https://github.com/tact-lang/tact/pull/212)
- The `del` method for the `Map` type: PR [#95](https://github.com/tact-lang/tact/pull/95)
- The `-h`/`--help`, `-v` (short for `--version`), `-p` (short for `--project`), `--func` (for only outputting FunC code) and `--check` (for only doing the syntax and type checking) command-line flags: PR [#287](https://github.com/tact-lang/tact/pull/287)
- The `mode` enum in project properties of `tact.config.json` for specifying compilation mode: `full` (default), `funcOnly` (only outputs FunC code and exits), or `checkOnly` (only does the syntax and type checking, then exits): PR [#287](https://github.com/tact-lang/tact/pull/287)

### Changed

Expand Down
3 changes: 1 addition & 2 deletions src/config/parseConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const projectSchema = z
path: z.string(),
output: z.string(),
options: optionsSchema.optional(),
checkOnly: z.boolean().optional(),
funcOnly: z.boolean().optional(),
mode: z.enum(["full", "checkOnly", "funcOnly"]).optional(),
})
.strict();

Expand Down
15 changes: 4 additions & 11 deletions src/pipeline/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,15 @@ export async function build(args: {
ctx = precompile(ctx, project, stdlib, config.path);
} catch (e) {
logger.error(
args.config.checkOnly || args.config.funcOnly
args.config.mode === "checkOnly" || args.config.mode === "funcOnly"
? "Syntax and type checking failed"
: "Tact compilation failed",
);
logger.error(errorToString(e));
return false;
}

if (args.config.checkOnly && args.config.funcOnly) {
logger.error(
"Checking is mutually exclusive with outputting only FunC code. Specify only one of those options in your tact.config.json!",
);
return false;
}

if (args.config.checkOnly) {
if (args.config.mode === "checkOnly") {
logger.log("✔️ Syntax and type checking succeeded.");
return true;
}
Expand Down Expand Up @@ -143,7 +136,7 @@ export async function build(args: {
continue;
}

if (args.config.funcOnly) {
if (args.config.mode === "funcOnly") {
continue;
}

Expand Down Expand Up @@ -218,7 +211,7 @@ export async function build(args: {
return false;
}

if (args.config.funcOnly) {
if (args.config.mode === "funcOnly") {
logger.log("✔️ FunC code generation succeeded.");
return true;
}
Expand Down

0 comments on commit 0b18c8c

Please sign in to comment.